I wish to change the time zone of the Jenkins.
I have changed the time zone of the Jenkins installed server, but the Jenkins UI shows the different time.
I need to set the PST time for Jenkins UI. How can I do it?
I wish to change the time zone of the Jenkins.
I have changed the time zone of the Jenkins installed server, but the Jenkins UI shows the different time.
I need to set the PST time for Jenkins UI. How can I do it?
On Jenkins2 you can set the timezone at runtime via the Groovy Console. Just open "Manage Jenkins >> Script Console" and type
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'America/Los_Angeles')
for example. Particularly helpful if you have no chance to change the startup variables but have admin rights on the instance. (often found in containerized setups). Only downside: Setting is gone on restart.
Login to jenkins and goto right top end and click on the user
then click on the configure and scroll down to last option "User Defined Time Zone" here you can find the different timezones.
I am using jenkins version 2.222.3.
See https://wiki.jenkins-ci.org/display/JENKINS/Change+time+zone. Jenkins should respect the timezone set for java. But you can force Jenkins to use a specific timezone by adding the following to start command of Jenkins:
java -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/Los_Angeles
This should set your timezone to PST.
While trying to find an answer to this, found that an issue is already open for this.
Though the issue status is OPEN, Unresolved
, I see an option to use the browser time zone at least for the Console Output
time stamps in Jenkins (2.60.2) >> <jobName> >> <build#>
:
I am using ubuntu version 16.04 and jenkins version Jenkins ver. 2.164.3
I tried using java -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/Los_Angeles
but didn't worked for me.
then I ended up using this command-
sudo dpkg-reconfigure tzdata
this will present you a GUI to set your timezone and then you have to restart jenkins via commands
Sudo /etc/init.d/jenkins stop
and
sudo /etc/init.d/jenkins start
Hope this helps! Cheers prateek
I went with the system-wide solution:
I have a bitnami image (which defaults to UTC) running on AWS (in us-east-2). All the work this server does is in my local timezone, and all the people who access it are local. So I changed /etc/timezone
and /etc/localtime
to Australia/Sydney and restarted Jenkins.
This section on executing startup scripts serves as a guide in executing typical Script Console code after EVERY bootup. Using this 'trick' will help permanently set properties via Groovy code. This is also easily maintainable.
https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/
If you are running Jenkins out of Docker container, then the below Dockerfile setup should work to update the timezone in Jenkins.
FROM jenkins/jenkins:lts-jdk11
USER root
# Install necessary packages
RUN apt-get update && apt-get install -y \
curl \
unzip
# update timezone
ENV TZ=Asia/Kolkata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
USER jenkins
ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/jenkins.yaml
COPY files/jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
COPY files/InitialConfig.groovy /usr/share/jenkins/ref/init.groovy.d/InitialConfig.groovy
COPY files/plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt