Jenkins uses the timezone set on the system where it is running by default but this can be overridden by specifying a different timezone in the Jenkins configuration.
This allows Jenkins to correctly display timestamps for builds regardless of the timezone of the machine where it is running or the timezone of the users viewing the build information.
This short post will explore setting our Jenkins instance’s time zone using the configuration file.
Jenkins Show Current Timezone
To view the currently set timezone, go to jenkins_server_url/systemInfo and see the user.timezone system property.
Jenkins Change Timezone
To change the set Timezone, edit the user configuration and scroll to the Timezone section. You can find this by going to your user configuration page where you can set the User Defined Time Zone.
Change Default Timezone as Admin
If you are a Jenkins administrator, you can change the default Timezone for the server by editing the Jenkins service unit as:
Edit the JAVA_OPTS variable and add the Timezone properties.
TZ is a java.util.TimeZone ID (“Europe/Monaco” for example).
An example complete configuration is as shown:
On windows, you need to edit the %INSTALL_PATH%/jenkins/jenkins.xml.
If you do not wish to restart the Jenkins server to apply the changes, you can use the Jenkins script console as:
Conclusion
This post covered the basics of viewing and changing the default timezone in a Jenkins server using various methods.