How to generate a docker with the desired plugins installed

Hello, I had a docker file to generate a docker image with the desired plugins installed. That docker file was using install-plugins.sh script. But after I downloaded the latest jenkins docker image, it has stoped working and gives me the following error: install-plugins.sh has been removed, please switch to jenkins-plugin-cli
But I have not been able to see how to run the jenkins cli during docker build. Could anybody provide a small dockerfile example so I can build my docker with the desired plugins?

My current dockerfile is the follwoing:

FROM jenkins/jenkins:lts-jdk11
LABEL maintainer="my-email@my-domain.com"
ENV JENKINS_USER my_user
ENV JENKINS_PASS my_password
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=true
RUN /usr/local/bin/install-plugins.sh bitbucket-build-status-notifier atlassian-jira-software-cloud docker-plugin docker-workflow blueocean

Thank you very much.

The Jenkins documentation for installing Jenkins with Docker includes a snippet like the following example Dockerfile:

FROM jenkins/jenkins:2.346.3-jdk11
RUN jenkins-plugin-cli --plugins "blueocean:1.25.6 docker-workflow:1.29"

More details are available at:

The Jenkins 2.346.2 upgrade guide also notes that install-plugins.sh has been replaced.

1 Like

I am trying this approach using a dockerfile but facing issue with plugins update site. I am using a plugins.txt file. I have tried from my client machine which is behind a proxy and also from my EC2 instance, EC2 doesn’t have any proxies, i am getting the same issues from both the servers.

Dockerfile:

FROM jenkins/jenkins:lts-jdk11

COPY --chown=jenkins:jenkins plugins.txt /usr/share/jenkins/ref/plugins.txt

#RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt

RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt && \
echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state

Error Logs:

Step 4/4 : RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt &&     echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
 ---> Running in 1dc5712c294c
Mar 15, 2023 8:00:27 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {s}->https://updates.jenkins.io:443: The target server failed to respond
Mar 15, 2023 8:00:27 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://updates.jenkins.io:443
Killed
The command '/bin/sh -c jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt &&     echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state' returned a non-zero code: 137