/fixexecutors Secret
Last active
August 10, 2018 17:34
-
-
Save pono/8ab92fddb9461cd62e45923b910ce81f to your computer and use it in GitHub Desktop.
set number of executors to 2 for a node in Jenkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hudson.slaves.DumbSlave | |
# $NODENAME is the node name in Jenkins | |
# NODENAME is just a variable | |
# newNODENAME is another variable | |
def NODENAME = Jenkins.instance.getNodesObject().getNode("$NODENAME") | |
# The "2" here sets the number of executors to 2 on the node | |
def newNODENAME = new DumbSlave( | |
NODENAME.getNodeName(), NODENAME.getNodeDescription(), NODENAME.getRemoteFS(), "2", NODENAME.getMode(), NODENAME.getLabelString(), NODENAME.getLauncher(), NODENAME.getRetentionStrategy(), NODENAME.getNodeProperties().toList()) | |
Jenkins.instance.getNodesObject().addNode(newNODENAME) |
i think this:
Jenkins.instance.getNodesObject().removeNode(n)
Jenkins.instance.getNodesObject().addNode(n)
can be replaced with this:
n.save()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def n = Jenkins.instance.getNodesObject().getNode("node-name-slave")
n.setNumExecutors(2)
Jenkins.instance.getNodesObject().removeNode(n)
Jenkins.instance.getNodesObject().addNode(n)