From 6ed7116980089b0e07dd8da4a5928165a11a61f3 Mon Sep 17 00:00:00 2001 From: Jordan Dea-Mattson Date: Wed, 12 Dec 2012 17:35:13 -0800 Subject: [PATCH 1/5] Add time_zone attribute with default value of UTC. Is in the format to be used as a JENKINS_JAVA_OPTIONS argument. --- attributes/default.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index 42caf88..4b19c86 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -25,6 +25,10 @@ default[:jenkins][:package_url] = "http://pkg.jenkins-ci.org" default[:jenkins][:java_home] = ENV['JAVA_HOME'] +# Set time zone by default to UTC. Set to your own time zone by using your Java Time Zone Code +# (ex. "America/Vancouver"). +default[:jenkins][:time_zone] = "-Dorg.apache.commons.jelly.tags.fmt.timeZone=Etc/UTC" + default[:jenkins][:server][:home] = "/var/lib/jenkins" default[:jenkins][:server][:user] = "jenkins" From ab4065278e4482f825262f5f0fb58c59a4eb400f Mon Sep 17 00:00:00 2001 From: Jordan Dea-Mattson Date: Wed, 12 Dec 2012 17:37:01 -0800 Subject: [PATCH 2/5] Add a JENKINS_JAVA_OPTIONS line to the jenkins config template. Set it to have an option to run headless and another for the time zone (which is captured from node.jenkins.time_zone) --- templates/default/jenkins.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/default/jenkins.erb b/templates/default/jenkins.erb index d759156..8c8bb9d 100644 --- a/templates/default/jenkins.erb +++ b/templates/default/jenkins.erb @@ -10,6 +10,9 @@ JAVA=/usr/bin/java #JAVA_ARGS="-Xmx256m" #JAVA_ARGS="-Djava.net.preferIPv4Stack=true" # make jenkins listen on IPv4 address +# Options to pass to Java when running Jenkins. +JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true <%= node.jenkins.time_zone %>" + PIDFILE=/var/run/jenkins/jenkins.pid # user id to be invoked as (otherwise will run as root; not wise!) From 7067429f0feba0f55d3c99be04e5be37898ed41c Mon Sep 17 00:00:00 2001 From: Jordan Dea-Mattson Date: Wed, 12 Dec 2012 17:38:19 -0800 Subject: [PATCH 3/5] Modify the default recipe to remove the jenkins config file at /etc/sysconfig/jenkins and then link /etc/default/jenkins to /etc/sysconfig/jenkins. This ensures that if jenkins is restarted via service at the command line, then we will use the same jenkins config file that is used when jenkins is started by chef. --- recipes/default.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/recipes/default.rb b/recipes/default.rb index 7c359e2..25c7a8e 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -156,6 +156,18 @@ template "/etc/default/jenkins" +file "/etc/sysconfig/jenkins" do + action :delete +end + +link "/etc/default/jenkins" do + to "/etc/sysconfig/jenkins" + link_type :symbolic + owner "root" + group "root" + action :create +end + package "jenkins" do action :nothing notifies :create, "template[/etc/default/jenkins]", :immediately From bf258b885d813c9765f477e9b650c76c8d08f227 Mon Sep 17 00:00:00 2001 From: Jordan Dea-Mattson Date: Wed, 12 Dec 2012 17:48:11 -0800 Subject: [PATCH 4/5] Fix typo "FIle.exists?" vs. "File.exists?" --- recipes/default.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/default.rb b/recipes/default.rb index 25c7a8e..198f5ca 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -158,8 +158,10 @@ file "/etc/sysconfig/jenkins" do action :delete + only_if {File.exists?("/etc/sysconfig/jenkins")} end + link "/etc/default/jenkins" do to "/etc/sysconfig/jenkins" link_type :symbolic From 10c764dbc163d0c5139c2c83bd04c8f4d6d0c069 Mon Sep 17 00:00:00 2001 From: Jordan Dea-Mattson Date: Wed, 12 Dec 2012 17:48:57 -0800 Subject: [PATCH 5/5] Trim white space. --- recipes/default.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/default.rb b/recipes/default.rb index 198f5ca..dcf3313 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -161,7 +161,6 @@ only_if {File.exists?("/etc/sysconfig/jenkins")} end - link "/etc/default/jenkins" do to "/etc/sysconfig/jenkins" link_type :symbolic