Specifying an agent in pipeline
The agent section specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent section is placed. The section must be defined at the top level inside the pipeline block, but stage-level usage is optional.
In agents declared at the outermost level of the Pipeline, we can specify the agent
// Matches our 'Slave 1' agent
agent {
label 'Slave 1'
}
// Matches agents with the CentOS label
agent {
label 'CentOS'
}
// Matches our 'master'
agent {
label 'master'
}
Stage Agents
If you want to execute a specific stage on an agent, you can specify the agent inside the specific stage
stage("pullrepoonnode") {
agent { label 'linux' }
steps {
git credentialsId: 'github', url: '[email protected]:zippyopstraining/myjdbc.git'
}
}
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post