IIUC, it's a normal behaviour.

The "build" pipeline step triggers the job job1 without any node "context"
(a bit like if you trigger it manually), so the default label of job1 is
used in this case.

If you want to trigger job1 with a specific label, you should have a look
to this plugin :
https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin
However, I never used it inside a Jenkins Pipeline.

Michaƫl

2016-12-14 13:23 GMT+01:00 <alexander.i...@gmail.com>:

> Hi,
>
> I'm trying to run a job at the node assigned (not the master node), but
> the job runs at any free node available (often it is the master node
> actually).
>
> Here's my pipeline script:
>
> node('label1') {
>   echo "Actual node name: $env.NODE_NAME ."
>   build job: 'job1'
> }
> node('master') {
>   echo "Actual node name: $env.NODE_NAME ."
> }
>
> My master node is not labeled with label 'label1'.
> Only one of my slave nodes is labeled with label 'label1'.
>
> I see at a build's Console Output that the 1st echo is executed at the
> slave node with label 'label1'. And the 2nd echo is executed at the master
> node.
> But 'job1' is executed at the master node also.
> I think that for my pipeline script 'job1' should be executed at the slave
> node labeled with 'label1'.
> 'job1' is allowed to run at any node (this is configured at the job's
> configuration).
>
> Is this behavior is correct? Or is it a bug when build-job-step ignores
> pipeline node assignment?
>
> For now I use Jenkins 2.8 and Pipeline Plugin 2.4 .
> I've tried both Windows and Linux slaves node with this case (got the same
> result). My master node is on Linux.
>
> Best regards,
> Alexander.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/77c72577-5898-4ccb-b0eb-cb9d1dab1d7e%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/77c72577-5898-4ccb-b0eb-cb9d1dab1d7e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAPO77c1_KFF_amMi-QCzj3Ab7sshHtZ4GuVs9c1hsrh%2Bw7PoAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to