Question:
So i'm running RHEL 7 on AWS with docker and jenkins (https://hub.docker.com/r/jenkinsci/blueocean/).
This article talks about how to change the timezone https://wiki.jenkins.io/display/JENKINS/Change+time+zone
essentially two ways
However i have created a volume for the settings folder this way
docker run -d -p 8080:8080 -v $PWD/jenkins:/var/jenkins_home:z -t jenkinsci/blueocean
this makes the home directory "jenkins-blue"
the directory listing is
4 -rw-r--r--. 1 <omitted user> 1647 Feb 27 17:00 config.xml
4 -rw-r--r--. 1 <omitted user> 3982 Feb 27 16:57 copy_reference_file.log
4 -rw-r--r--. 1 <omitted user> 966 Feb 27 17:04 credentials.xml
0 drwxr-xr-x. 3 <omitted user> 16 Feb 27 17:06 fingerprints
4 -rw-r--r--. 1 <omitted user> 156 Feb 27 16:57 hudson.model.UpdateCenter.xml
4 -rw-r--r--. 1 <omitted user> 1230 Feb 27 17:07 hudson.plugins.emailext.ExtendedEmailPublisher.xml
4 -rw-r--r--. 1 <omitted user> 370 Feb 27 16:58 hudson.plugins.git.GitTool.xml
4 -rw-------. 1 <omitted user> 1712 Feb 27 16:57 identity.key.enc
0 drwxr-xr-x. 2 <omitted user> 41 Feb 27 16:57 init.groovy.d
4 -rw-r--r--. 1 <omitted user> 94 Feb 27 16:58 jenkins.CLI.xml
4 -rw-r--r--. 1 <omitted user> 7 Feb 27 17:00 jenkins.install.InstallUtil.lastExecVersion
4 -rw-r--r--. 1 <omitted user> 7 Feb 27 17:00 jenkins.install.UpgradeWizard.state
4 -rw-r--r--. 1 <omitted user> 183 Feb 27 17:00 jenkins.model.JenkinsLocationConfiguration.xml
4 -rw-r--r--. 1 <omitted user> 171 Feb 27 16:57 jenkins.telemetry.Correlator.xml
0 drwxr-xr-x. 3 <omitted user> 18 Feb 27 17:00 jobs
0 drwxr-xr-x. 4 <omitted user> 37 Feb 27 16:58 logs
4 -rw-r--r--. 1 <omitted user> 907 Feb 27 16:58 nodeMonitors.xml
0 drwxr-xr-x. 2 <omitted user> 6 Feb 27 16:58 nodes
20 drwxr-xr-x. 106 <omitted user> 16384 Feb 27 16:59 plugins
4 -rw-r--r--. 1 <omitted user> 129 Feb 28 17:35 queue.xml
4 -rw-r--r--. 1 <omitted user> 64 Feb 27 16:57 secret.key
0 -rw-r--r--. 1 <omitted user> 0 Feb 27 16:57 secret.key.not-so-secret
4 drwx------. 4 <omitted user> 4096 Feb 27 17:14 secrets
0 drwxr-xr-x. 2 <omitted user> 182 Feb 27 16:59 updates
0 drwxr-xr-x. 2 <omitted user> 24 Feb 27 16:58 userContent
0 drwxr-xr-x. 3 <omitted user> 57 Feb 27 17:00 users
4 drwxr-xr-x. 11 <omitted user> 4096 Feb 27 16:57 war
0 drwxr-xr-x. 2 <omitted user> 6 Feb 27 16:58 workflow-libs
0 drwxr-xr-x. 4 <omitted user> 34 Feb 27 17:06 workspace
To see the time zone currently set, go to jenkins_server/systemInfo and see the user. timezone system property. You may want to change the time zone displayed to match your own time zone. By going to your user configuration page, you can set the User Defined Time Zone to match your own.
The easiest way to change the time in a Docker container is to change the time using 'date' command after connecting to the container. Though the time zone change usually reflects immediately, in some cases, the container needs a restart for the time to change.
The directory /usr/share/zoneinfo in Docker contains the container time zones available. The desired time zone from this folder can be copied to /etc/localtime file, to set as default time. The containers created out of this Dockerfile will have the same timezone as the host OS (as set in /etc/localtime file).
You may apply a TZ environment into your docker-compose like this:
image: jenkins/jenkins:alpine
container_name: jenkins
hostname: jenkins
restart: always
environment:
- TZ=Asia/Shanghai
volumes:
- ./jenkins/data:/var/jenkins_home
- ./jenkins/bin/jenkins.war:/usr/share/jenkins/jenkins.war
Run it in System Management -> Script command line
:
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone',
'Asia/Shanghai')
https://wiki.jenkins.io/display/JENKINS/Change+time+zone
BTW, I add this in my Timed tasks:
TZ=Asia/Shanghai
40 15 * * 1-5
OR
docker run ... -e JAVA_OPTS=-Duser.timezone=Asia/Shanghai
https://github.com/jenkinsci/docker/issues/45
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