Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djom202/c74cd7b2473c01ac24b9eb4ea63c9404 to your computer and use it in GitHub Desktop.
Save djom202/c74cd7b2473c01ac24b9eb4ea63c9404 to your computer and use it in GitHub Desktop.
Jenkins - Set number of executors via groovy script - #jenkins #groovy
#!groovy
// imports
import jenkins.model.Jenkins
// parameter
Integer numberOfExecutors = 2
// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()
// set the number of slaves
jenkins.setNumExecutors(numberOfExecutors)
// save current Jenkins state to disk
jenkins.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment