Find file History
Pull request Compare This branch is 233 commits ahead, 1174 commits behind chef:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Installs and configures Hudson CI server & node slaves. Resource providers to support automation via hudson-cli, including job create/update.



  • Chef version 0.9.10 or higher


  • 'default' - Server installation - currently supports Red Hat/CentOS 5.x and Ubuntu 9.x/10.4

  • 'node_ssh' - Any platform that is running sshd.

  • 'node_jnlp' - Unix platforms. (depends on runit recipe)

  • 'node_windows' - Windows platforms only. Depends on .NET Framework, which can be installed with the windows::dotnetfx recipe.


Hudson requires Java 1.5 or higher, which can be installed via the Opscode java cookbook or windows::java recipe.

Hudson node authentication:

If your Hudson instance requires authentication, you'll either need to embed user:pass in the hudson.server.url or issue a hudson-cli.jar login command prior to using the hudson::node_* recipes. For example, define a role like so:

name "hudson_ssh_node"
description "cli login & register ssh slave with Hudson"
run_list %w(vmw::hudson_login hudson::node_ssh)

Where the hudson_login recipe is simply:

hudson_cli "login --username #{node[:hudson][:username]} --password #{node[:hudson][:password]}"


  • hudson - Base URL for downloading Hudson (server)

  • hudson - Java install path, used for for cli commands

  • hudson[:home] - HUDSON_HOME directory

  • hudson[:user] - User the Hudson server runs as

  • hudson[:group] - Hudson user primary group

  • hudson[:port] - TCP listen port for the Hudson server

  • hudson[:url] - Base URL of the Hudson server

  • hudson[:plugins] - Download the latest version of plugins in this list, bypassing update center

  • hudson[:name] - Name of the node within Hudson

  • hudson[:description] - Hudson node description

  • hudson[:executors] - Number of node executors

  • hudson[:home] - Home directory (“Remote FS root”) of the node

  • hudson[:labels] - Node labels

  • hudson[:mode] - Node usage mode, “normal” or “exclusive” (tied jobs only)

  • hudson[:launcher] - Node launch method, “jnlp”, “ssh” or “command”

  • hudson[:availability] - “always” keeps node on-line, “demand” off-lines when idle

  • hudson[:in_demand_delay] - number of minutes for which jobs must be waiting in the queue before attempting to launch this slave.

  • hudson[:idle_delay] - number of minutes that this slave must remain idle before taking it off-line.

  • hudson[:env] - “Node Properties” -> “Environment Variables”

  • hudson[:user] - user the slave runs as

  • hudson[:ssh_host] - Hostname or IP Hudson should connect to when launching an SSH slave

  • hudson[:ssh_port] - SSH slave port

  • hudson[:ssh_user] - SSH slave user name (only required if hudson server and slave user is different)

  • hudson[:ssh_pass] - SSH slave password (not required when server is installed via default recipe)

  • hudson[:ssh_private_key] - hudson master defaults to: `~/.ssh/id_rsa` (created by the default recipe)

  • hudson[:jvm_options] - SSH slave JVM options


'default' recipe

Installs a Hudson CI server using the RPM. The recipe also generates an ssh private key and stores the ssh public key in the node 'hudson' attribute for use by the node recipes.

'node_ssh' recipe

Creates the user and group for the Hudson slave to run as and sets `.ssh/authorized_keys` to the 'hudson' attribute. The 'hudson-cli.jar’ is downloaded from the Hudson server and used to manage the nodes via the 'groovy’ cli command. Hudson is configured to launch a slave agent on the node using its SSH slave plugin.




'node_jnlp' recipe

Creates the user and group for the Hudson slave to run as and '/jnlpJars/slave.jar' is downloaded from the Hudson server. Depends on runit_service from the runit cookbook.

'node_windows' recipe

Creates the home directory for the node slave and sets 'HUDSON_HOME' and 'HUDSON_URL' system environment variables. The 'winsw’ Windows service wrapper will be downloaded and installed, along with generating `hudson-slave.xml` from a template. Hudson is configured with the node as a 'jnlp’ slave and '/jnlpJars/slave.jar' is downloaded from the Hudson server. The 'hudsonslave' service will be started the first time the recipe is run or if the service is not running. The 'hudsonslave' service will be restarted if '/jnlpJars/slave.jar' has changed. The end results is functionally the same had you chosen the option to “Let Hudson control this slave as a Windows service”.




'hudson_cli' resource provider

This resource can be used to execute the Hudson cli from your recipes. For example, install plugins via update center and restart Hudson:

%w(git URLSCM build-publisher).each do |plugin|
  hudson_cli "install-plugin #{plugin}"
  hudson_cli "safe-restart"

'hudson_node' resource provider

This resource can be used to configure nodes as the 'node_ssh' and 'node_windows' recipes do or “Launch slave via execution of command on the Master”.

hudson_node node[:fqdn] do
  description  "My node for things, stuff and whatnot"
  executors    5
  remote_fs    "/var/hudson"
  launcher     "command"
  command      "ssh -i my_key #{node[:fqdn]} java -jar #{remote_fs}/slave.jar"
  env          "ANT_HOME" => "/usr/local/ant", "M2_REPO" => "/dev/null"

'hudson_job' resource provider

This resource manages hudson jobs, supporting the following actions:

:create, :update, :delete, :build, :disable, :enable

The 'create' and 'update' actions require a hudson job config.xml. Example:

git_branch = 'master'
job_name = "sigar-#{branch}-#{node[:os]}-#{node[:kernel][:machine]}"

job_config = File.join(node[:hudson][:node][:home], "#{job_name}-config.xml")

hudson_job job_name do
  action :nothing
  config job_config

template job_config do
  source "sigar-hudson-config.xml"
  variables :job_name => job_name, :branch => git_branch, :node => node[:fqdn]
  notifies :update, resources(:hudson_job => job_name), :immediately
  notifies :build, resources(:hudson_job => job_name), :immediately

'manage_node' library

The script to generate groovy that manages a node can be used standalone. For example:

% ruby manage_node.rb name slave-hostname remote_fs /home/hudson ... | java -jar hudson-cli.jar -s http://hudson:8080/ groovy =




Doug MacEachern (<>)


2010, VMware, Inc

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.