Declarative Pipeline - Selecting agent based on branch

14 views
Skip to first unread message

Abishek Manoharan

unread,
Aug 15, 2017, 12:07:27 AM8/15/17
to Jenkins Users
I have a multi-branch pipeline setup and would like to execute more stages when building on the "master" branch. This means, I also have to run the pipeline on a different agent when running on the master branch.
Is it possible to specify the agent based on a condition in the Jenkinsfile?

Something like,

pipeline {
    agent
{
        label env
.BRANCH_NAME == "master" ? "MasterAgent" : "OtherAgent"
   
}
}

Or some other way to achieve this requirement?
Reply all
Reply to author
Forward
0 new messages