export JENKINS_HOST=username:password@myhost.com:port
curl -sSL "http://$JENKINS_HOST/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'|sed 's/ /:/' > plugins.txt
plugins.txt
will now have all the plugins of the current installation
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && apt-get install -y ruby curl
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false \
-Djava.awt.headless=true \
-Dhudson.model.ParametersAction.keepUndefinedParameters=true
USER jenkins
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
docker build . -t my-jenkins
docker run -d -p 49002:8080 -v ~/jenkins_home:/var/jenkins_home -t my-jenkins
Inspect the loading process: docker logs -f [container-id]