Set node label in jenkins pipeline

Can I set a label instead of a name for Groovy nodes? We want to define labels outside the script so that we can easily access them from the Jenkins toolbar.

Idea: Instead:


Groovy script

node('Slave_1 || Slave_2'){ echo 'Hello world' }

We want something like this:


Pipeline configuration

Node Label Name:     slaveGroup
Node Label Value:    Slave_1 || Slave_2

Groovy script

node(slaveGroup){echo 'Hello world'}

Or can you use labels that you can set in the sub configuration directly in the Groovy script?

+4
source share
1 answer

It just turned out that the Pipline (Generator) syntax provides this option:

Valid Operators

The following operators are supported in order of priority.

(expression)

bracket

! Expression

negation

expression && expression

and

expression || expression

or

a โ†’ b

"" . ! A | b. , windows- > x64 " Windows, 64 ". - Jenkins Linux.

a โ†” b

" , . & b ||! & &! . , windows โ†” sfbay " Windows, SF-, Windows, ".

(.. a- > b- > c โ†” (a- > b) โ†’ c) An , .

, . ," jenkins-solaris (Solaris) "||" Windows 2008"

.

+4

Source: https://habr.com/ru/post/1670029/


All Articles