How to make Jenkins CI use Local time instead of UTC on debian squeeze

Solution 1:

You need to pass in your required value of user.timezone as a JVM argument when you start Jenkins. The Java command line will look something like:

$JAVA_HOME/java -Duser.timezone="America/Toronto" [other JVM parameters] $JENKINS_HOME/jenkins.jar

Unfortunately I'm not familiar with the Debian installation, but the JVM parameters should either be defined in the /etc/init.d/jenkins script or in a properties file that is referenced from that script.

Solution 2:

Three years later, I found several gotchas getting this to work. So, I'll elaborate upon the accepted answer (which is correct) and add a complete answer for CentOS.


Gotcha #1: The Jenkins settings to change

The current Jenkins documentation on changing time zone says to define user.timezone or org.apache.commons.jelly.tags.fmt.timeZone. But, I have found that both are necessary. The jelly one works for Jenkins proper and some plugins, while the user one works for other plugins.


Gotcha #2: The OS settings to update

For CentOS in the Eastern US, edit /etc/sysconfig/jenkins to:

JENKINS_JAVA_OPTIONS="-Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York -Duser.timezone=America/New_York"
JENKINS_ARGS=""

If you put these -D settings into JENKINS_ARGS, it won't work.


Gotcha #3: Restarting

You have to restart from the command line, the entire service. Simply doing a Jenkins safe restart is not sufficient. So:

sudo service jenkins restart

When you've done all this, check that both time zone settings match in your Jenkins system information panel: http://jenkins.example.com/systemInfo


Solution 3:

In Ubuntu 14.04, none of the above solutions worked for me, but I ended up running the following command, which pulls up an interface where the timezone can be changed from the default (none selected) to something more specific:

sudo dpkg-reconfigure tzdata

First, you're prompted to select the continent, (i.e. America, Asia, etc) and then the city, which in my case resulted in "Asia/Kolkata" for the IST timezone in India.

See UbuntuTime - Using the Command Line.

In addition, after changing the timezone, I restarted Jenkins:

sudo /etc/init.d/jenkins stop sudo /etc/init.d/jenkins start

and then verified that the time was in local IST time. In http://<yourservername>/systemInfo, as provided by user bishop, under the System Properties section, for the "user.timezone" property, I now see "Asia/Kolkata" as its value.


Solution 4:

If this relates to the execution of jobs based on a cron schedule (ie Build Periodically), you can set you Time Zone in the cron schedule on a per job basis:

TZ=Europe/Dublin
0 7 * * 1-5

Solution 5:

If you are running Jenkins in Apache Tomcat, add these to <Apache-Tomcat-Dir>/conf/catalina.properties:

user.timezone=America/New_York
org.apache.commons.jelly.tags.fmt.timeZone=America/New_York

Both are needed.