Search code examples
jenkinsjenkins-pipeline

How to use a "backup node" in Jenkins?


I have a job that gets triggered automatically, let's call it JobA and I have two nodes NodeA and NodeB. I want JobA to always run only on NodeA, but if NodeA is offline I want it to run on NodeB. How can is set this up?

Currently JobA only uses NodeA. If the node if offline the build is not executed.


Solution

  • It could be something like below. more details you can explore here

    pipeline {
      agent { label 'NodeA || NodeB' }
      stages {
         stage('stage-one') {
           steps {
              ....
           }
         }
      }
    }