Declarative Pipeline - Agent wonderment

22 views
Skip to first unread message

Danny Rehelis

unread,
Apr 20, 2017, 9:02:27 AM4/20/17
to Jenkins Users
Help me understand this please, in case my Pipeline looks like this -

pipeline {
    agent none
    stages {
        stage ('Stage #1') {
agent { label 'builder' }
            steps {
echo "Hello World"
}
}
        stage ('Stage #2') {
agent { label 'builder' }
            steps {
echo "Hello World"
}
}
}
}

Will the second stage run on the same builder labeled server instance (same one from first stage) or will pick any other possibly idle labeled server available at the time?
Is it possible to force "stickiness" for explicitly configured agents?

Christopher Orr

unread,
Apr 25, 2017, 5:16:51 AM4/25/17
to jenkins...@googlegroups.com
On Thu, 20 Apr 2017, at 15:02, Danny Rehelis wrote:
> Help me understand this please, in case my Pipeline looks like this -
>
> stage ('Stage #1') {
> agent { label 'builder' }
> stage ('Stage #2') {
> agent { label 'builder' }
>
> Will the second stage run on the same builder labeled server instance
> (same one from first stage) or will pick any other possibly idle labeled server
> available at the time?
> Is it possible to force "stickiness" for explicitly configured agents?

In this case, there's no guarantee that the two builds will run in the
same workspace, or even on the same agent, if there are multiple agents
with the 'builder' label.

For stickiness, you'd probably have to define your `agent` once at the
top level of the Pipeline, and then maybe do `agent none` in the stages
where you don't need that agent (not entirely sure whether that works).

Regards,
Chris
Reply all
Reply to author
Forward
0 new messages