2

In my declarative pipeline, i need to select a node matching 2 labels. I tried something like this

agent { label 'label1 && label2'}

But i get an error that there are no nodes. I have a node with 2 labels label1 and label2 associated.

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Still waiting to schedule task
There are no nodes with the label ‘label1&&label2’

I know that i could temportailiy fix this by creating a 3rd label label1-2 and associate it with agent in the pipeline.

Is there any proper way to fix this?

KitKarson
  • 5,211
  • 10
  • 51
  • 73
  • @KitKat, `agent { label 'label1 && label2'}` is correct. As pointed out by @Yap below, your own answer is misleading, since it matches any node that has _either_ of the labels. Please fix your answer to prevent others from being misled. – Landschaft Nov 10 '22 at 07:38

1 Answers1

8

Ok..figured it out.

agent {label "label1" && "label2"}
KitKarson
  • 5,211
  • 10
  • 51
  • 73
  • @VonC, hi, you are good at jenkins. Can you please help clarifying this for me - https://stackoverflow.com/questions/54772043/jenkinsfile-how-to-pass-parameters-for-all-the-stages – KitKarson Feb 19 '19 at 19:28
  • 4
    actually, correct is to use 'label1 && label2' . with your approach, only any of the label was match, not both at same time. are you sure you have a node having both labels? – YaP Oct 18 '19 at 06:58