Limiting the Jenkins pipeline to work on specific nodes only

I create jobs that will make heavy use of the Jenkins lines. Our nodes are designated for each project by their tags, but, unlike ordinary tasks, the assembly of the pipeline does not seem to have a checkbox "Limit where this project can be launched." How can I indicate on which node the pipeline will work, as I do for regular tasks?

+5
source share
2 answers

You specify the desired node or tag when you execute the node step:

 node('specialSlave') { // Will run on the slave with name or tag specialSlave } 

See https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#code-node-code-allocate-node for an extended explanation of node arguments.

+8
source

For the record, give here a declarative pipeline (by choosing a node that has the label "X"):

 pipeline { agent { label 'X' } ... ... } 
+4
source

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


All Articles