I had this in my Dockerfile:
FROM jenkins
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
Plugins.txt (which is in the same folder as the Dockerfile):
gradle:1.26
junit:1.18
I ran:
docker build . --tag test-jenkins --no-cache
Sending build context to Docker daemon 3.072 kB
Step 1/3 : FROM jenkins
---> 59b08e8f6e37
Step 2/3 : COPY plugins.txt /usr/share/jenkins/plugins.txt
---> 212babaf63db
Removing intermediate container 2f12ff3a424d
Step 3/3 : RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/plugins.txt
---> Running in 377c86b2e39d
Creating initial locks...
Analyzing war...
Downloading plugins...
WAR bundled plugins:
Installed plugins:
*:
Cleaning up locks
rm: cannot remove ‘/usr/share/jenkins/ref/plugins/*.lock’: No such file or directory
The command '/bin/sh -c /usr/local/bin/install-plugins.sh < /usr/share/jenkins/plugins.txt' returned a non-zero code: 1
Sending build context to Docker daemon 3.072 kB
Step 1/4 : FROM jenkins
---> 59b08e8f6e37
Step 2/4 : COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
---> 5c7a8e90a55e
Removing intermediate container 8d75ac2282ad
Step 3/4 : RUN /usr/local/bin/install-plugins.sh gradle:1.26 junit:1.18
---> Running in ccbf73e31a7d
Creating initial locks...
Analyzing war...
Downloading plugins...
Downloading plugin: gradle from https://updates.jenkins.io/download/plugins/gradle/1.26/gradle.hpi
Downloading plugin: junit from https://updates.jenkins.io/download/plugins/junit/1.18/junit.hpi
> gradle depends on structs:1.3
Downloading plugin: structs from https://updates.jenkins.io/download/plugins/structs/latest/structs.hpi
> junit depends on structs:1.2
WAR bundled plugins:
Installed plugins:
gradle:1.26
junit:1.18
structs:1.7
Cleaning up locks
---> edfd95c8e270
Removing intermediate container ccbf73e31a7d
Step 4/4 : RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
---> Running in cf66161c6d52
---> 367ab182ea17
Removing intermediate container cf66161c6d52
Successfully built 367ab182ea17
No
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:14:09 2017
OS/Arch: linux/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:14:09 2017
OS/Arch: linux/amd64
Experimental: false
It does work when I don't use the plugins.txt. This Dockerfile generates the expected outcome:
FROM jenkins
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh gradle:1.26 junit:1.18
RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
That feature is not included in the latest LTS image yet, you can use weekly builds or the other ways to install plugins
@WKoopa As a workaround, you can use xargs:
RUN xargs /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
The contents of plugins.txt get passed to xargs which then feeds them to install-plugins.sh as command-line parameters.
Most helpful comment
@WKoopa As a workaround, you can use
xargs:The contents of
plugins.txtget passed toxargswhich then feeds them toinstall-plugins.shas command-line parameters.