Jenkins

Set Timezone in Jenkins

Timezone is a setting that allows you to specify the timezone that should be used for various timestamps associated with builds, such as the build start and completion times.

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:

$ sudo systemctl edit jenkins

Edit the JAVA_OPTS variable and add the Timezone properties.

java -Dorg.apache.commons.jelly.tags.fmt.timeZone=TZ

TZ is a java.util.TimeZone ID (“Europe/Monaco” for example).

An example complete configuration is as shown:

Environment="JAVA_OPTS=-Dorg.apache.commons.jelly.tags.fmt.timeZone=Europe/Moncao"

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:

System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'Europe/Monaco')

Conclusion

This post covered the basics of viewing and changing the default timezone in a Jenkins server using various methods.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list