Modify the logging configuration
Warn : Jenkins relies on java.util.logging.
Beware of level to specify : https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html
For direct OS installations, modify the script that run jenkins to set a system property when the JVM is run :
-Djava.util.logging.config.file=/var/jenkins_home/logging.properties
For docker installation, set the JAVA_OPTS environment variable when you run the container :
-e JAVA_OPTS='-Djava.util.logging.config.file=/var/jenkins_home/logging.properties'
Example of logging.properties to log many things :
.level = FINEST handlers= java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level=FINEST java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter hudson = FINEST #hudson.plugins.git.GitStatus.level = ERROR |
Other…
Jenkins with docker : installation and runtime info
Location of the Jenkins install : stored in the JENKINS_HOME
env variable.
By default, that is JENKINS_HOME=/var/jenkins_home
.
Jenkins docker image user
The user/group is : uid=1000(jenkins) gid=1000(jenkins).
To change the Jenkins port in the container:
– without docker : set the env variable : JENKINS_OPTS=--httpPort=8081
.
– with docker : we set it when we run the container in this way
:
docker run ... -e JENKINS_OPTS='--httpPort=8081' -p extPort:8081 ... jenkinsImage
To run Jenkins as a container with the the Docker with many options :
– run the container as root. it is not the best choice. A better alternative (if we have rights) is specifying a user that for the directory /var/run/docker.sock has the same user and group id that on the host
– using the host network stack (it is not necessary to use Docker in Jenkins)
– changing the port. Here we have only one as we use the host network
– giving a specific name to the image to reuse it in a service (systemd for example),
– setting the logging properties
– enabling the restart policy to start at startup
– mounting a volume for the data
– mounting another one for the docker daemon listener (needed if we use docker agent in the pipelines) :
docker run \ -u root \ -d \ --name=my-jenkins \ --network='host' \ --restart=unless-stopped \ -e JENKINS_OPTS='--httpPort=8081' \ -e JAVA_OPTS='-Djava.util.logging.config.file=/var/jenkins_home/logging.properties' \ -v jenkins-data:/var/jenkins_home \ -v /var/run/docker.sock:/var/run/docker.sock \ jenkinsci/blueocean |
Data storage directory
Without DOCKER : $JENKINS_HOME
.
With DOCKER : container directory :
./var/jenkins_home
/
Backup data
Backup the data storage directory
Install plugin manually
Copy the plugin file(.hpi file) in the $JENKINS_HOME/plugins/
directory
Update jenkins
– Backup the data directory
– No docker : Download the new WAR and deploy it
– docker : update the image version of Jenkins/BlueOcean
Warn :
If the version shift is important, many plugins errors and many application logs errors will appear.
As well as the configuration of some plugin may be unavailable and existing jobs could miss configurations or be usable.
To fix that :
– check the installed plugins that cause troubles and update or remove them if not required any longer.
– checks Jenkins alerts on the top right GUI.
If you have a message that looks like « You have data stored in an older format and/or unreadable data », check that jobs related are OK (try to save them via the GUI to check that they work)
– check jenkins errors logs. Update any plugin that fails and restart jenkins. Go on while you have any errors