I've just met some problem with slave creation.
I need to create slave machines on demand, so
I'm creating DumbSlave as follow:
def createJenkinsNode() {
def sshCredentials = settings['jenkins']['ssh_credentials']
SSHLauncher launcher = new SSHLauncher("10.1.1.10", 22,
sshCredentials, "", "", , "", "")
def dumbSlave= new DumbSlave(
"some_name",
"/home/jenkins",
launcher
)
dumbSlave.numExecutors = 1
dumbSlave.mode = Node.Mode.EXCLUSIVE
dumbSlave.labelString = 'some_label'
dumbSlave.retentionStrategy = new RetentionStrategy.Always()
Jenkins.instance.addNode(dumbSlave)
}
After that, I can use it in my pipeline and run some commands:
....
stage("Build") {
node("some_name") {
echo "Running on the slave machine"
sh "sleep 50"
}
}
Everything works fine until the slave goes offline or something happens
with the network connection during the job execution. If this happens,
Jenkins's infinitely trying to reconnect to the slave, but if slave or
connection never come back, the job is stuck forever.
One solution that comes to my mind is to wrap the code inside "stage" block
in "timeout" block:
....
stage("Build") {
timeout(1) {
node("some_name") {
echo "Running on the slave machine"
sh "sleep 50"
}
}
}
I don't like this approach because I have to specify timeouts instead of
event handling.
I believe something could be done with the help of
`RetentionStrategy.Demand()` but I'm not sure.
How can I stop the job if Jenkins is not able to connect to the slave after
one or two attempts?
Question on stackoverflow.com:
https://stackoverflow.com/questions/46521492/jenkins-stop-trying-to-reconnect-to-the-slave-if-it-is-offline
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/10741358-db42-4ba7-9d93-1cb1ed4f23fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.