Cryptocracy

A blog

Increasing Jenkins Executors With Chef

By default, Jenkins is configured to run one “build executor” for each core in the server. This is a reasonable default for CPU-bound workloads (like most compile/test jobs), but it’s a bit pessimistic in my case – CI pipelines for my Chef cookbooks.

Fortunately, the executor count can be increased with a small Groovy script – this thread on StackOverflow told me what I needed to know.

If you’re already using the Jenkins cookbook to manage your Jenkins server, you can run two executors per core like so:

1
2
3
4
5
6
7
8
9
10
11
jenkins_script 'set number of executors' do
  command <<-EOF
import hudson.model.*

// Set executors to twice the number of CPU cores
Hudson hudson = Hudson.getInstance()
hudson.setNumExecutors(#{node['cpu']['total'] * 2})
hudson.setNodes(hudson.getNodes())
hudson.save()
  EOF
end

Comments