I'm trying to create my own Jenkins image that skips the wizard and sets the admin password via an environment variable.
I tried setting the state to disable it (taken from the Mesosphere Jenkins service) but that didn't work:
# disable first-run wizard
RUN echo 2.0 > ${JENKINS_STAGING}/jenkins.install.UpgradeWizard.state
How can I skip the wizard and set the admin password via a variable instead of the password being auto-generated?
If you are using the jenkins/jenkins image from Docker Hub ( https://hub.docker.com/r/jenkins/jenkins/ ), then you can disable the setup wizard by setting this environment variable:
JAVA_OPTS=-Djenkins.install.runSetupWizard=false
And to pre-configure the admin user, you can do that with this environment varible:
JENKINS_OPTS=--argumentsRealm.roles.user=admin --argumentsRealm.passwd.admin=admin --argumentsRealm.roles.admin=admin
Here's a docker-compose example which I've been using locally:
version: '3'
services:
jenkins:
image: jenkins/jenkins:2.150.3-alpine
environment:
JAVA_OPTS: -Djenkins.install.runSetupWizard=false
JENKINS_OPTS: --argumentsRealm.roles.user=admin --argumentsRealm.passwd.admin=admin --argumentsRealm.roles.admin=admin
volumes:
- ./jenkins_home:/var/jenkins_home
ports:
- 8080:8080
The correct way to set the admin password is to start Jenkins with parameters:
java ${JVM_OPTS} \
-Dhudson.udp=-1 \
-Djava.awt.headless=true \
-Dhudson.DNSMultiCast.disabled=true \
-Djenkins.install.runSetupWizard=false \
-jar ${JENKINS_FOLDER}/jenkins.war \
${JENKINS_OPTS} \
--httpPort=${PORT1} \
--webroot=${JENKINS_FOLDER}/war \
--ajp13Port=-1 \
--httpListenAddress=0.0.0.0 \
--ajp13ListenAddress=0.0.0.0 \
--argumentsRealm.passwd.admin=${PASSWORD} \
--argumentsRealm.roles.user=admin \
--argumentsRealm.roles.admin=admin \
--prefix=${JENKINS_CONTEXT}
In this case the --argumentsRealm* parameters are the most important as they set the role and the password for admin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With