I have a simple Dockerfile where I install Jenkins and some plugins:
FROM jenkins/jenkins:2.169-alpine
USER root
RUN apk update \
&& apk add --no-cache curl docker jq tzdata \
&& rm -rf /var/cache/apk/*
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/plugins.txt
There is now a jenkins plugin with a custom patch I would need to include. There's already a PR open for it but it's been months it was not merged and I can't wait anymore, so I'd like to add a step to install a plugin from a branch of my github repo.
I found out that after the jenkins-cli.jar
is available (so, not at build time), one can install a plugin in hpi
format doing:
java -jar /var/jenkins_home/war/WEB-INF/jenkins-cli.jar \\ -auth user:password \\ -s http://localhost:8080 install-plugin file://<HPI_PATH>
but it cannot work at build time. If not possible in the dockerfile, is there an alternative?
First build the plugin.hpi locally and then Use copy or Add in Dockerfile to add plugin into jenkins docker images in build step.
example Add https://updates.jenkins-ci.org/download/plugins/sonar/2.8.1/sonar.hpi /var/jenkins_home/plugins/
Or
Install sonar plugin using local build hpi file.
Copy sonar.hpi /var/jenkins_home/plugins/
After digging PR, I found the solution here https://github.com/jenkinsci/docker/pull/799
This is not an install from github but it will work out
So you just need to add at the end of your dockerfile (being root and not jenkins user):
RUN /usr/local/bin/install-plugins.sh plugin-name:plugin-version:hpi-url
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.