I have a pipeline that runs on a dedicated bare metal node for automated performance benchmarking. Using bare metal is necessary due to the nature of the project.
Near the end of the pipeline, the results are sent to users (simply seeing a pass or fail status is not sufficient).
To provide each instance of the pipeline a clean slate, the node is rebooted at the end of the pipeline. This makes the pipeline appear stuck in Jenkins. Several minutes after Jenkins is able to reconnect to the node, Jenkins realizes the pipeline that was running ended abruptly, and marks it failed:
+ sudo reboot
Cannot contact baremetal: hudson.remoting.ChannelClosedException: Channel "hudson.remoting.Channel@35ca6b21: baremetal": Remote call on baremetal failed. The channel is closing down or has closed down
wrapper script does not seem to be touching the log file in /home/jenkins/workspace/bare-metal-benchmarks@tmp/durable-e96e9611
(JENKINS-48300: if on an extremely laggy filesystem, consider -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.HEARTBEAT_CHECK_INTERVAL=86400)
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -1
Setting status of *** to FAILURE with url *** and message: ' '
Using context: Bare Metal Benchmarks
Finished: FAILURE
The next instance of this pipeline can then start running on the rebooted bare metal node.
Is there a way to safely reboot a node at the end of a pipeline so Jenkins does not mark the pipeline status as failed?
The basic structure of the scripted pipeline is:
node('baremetal') {
checkout scm
try {
stage('Benchmarks') {
// run benchmarks
}
stage('Process data') {
// process data and send results to users
}
}
finally {
stage('Clean up') {
sh 'sudo reboot'
}
}
}