'How to choose between two agents for high-availability in Jenkins pipeline
I have several agents configured in Jenkins.
For one of my pipeline jobs execution, I wish to choose between two of my agents i.e. MYHOST11-ANSIBLE-SLAVE and MYHOST22-ANSIBLE-SLAVE which ever is available. Thus, if MYHOST11-ANSIBLE-SLAVE is unavailable my Jenkins pipeline job should switch to using MYHOST22-ANSIBLE-SLAVE
Can you please suggest what changes do I need in my below pipeline code ?
pipeline {
agent {
node {
label 'MYHOST11-ANSIBLE-SLAVE'
}
}
stages {
stage('Precheck') {
steps {
sh "echo Im from Jenkins>/tmp/jenkinsmoht.txt"
Note: I want my pipeline to choose only between the two agents I mentioned as only they have ansible with my pipeline invokes. Other agents don't have ansible thus my pipeline would fail.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
