Limiting Jenkins pipeline to running only on specific nodes

后端 未结 3 1625
南方客
南方客 2021-02-03 17:25

I\'m building jobs that will be using Jenkins piplines extensively. Our nodes are designated per project by their tags, but unlike regular jobs the pipeline build does not seem

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-03 17:49

    You specify the desired node or tag when you do 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/#node-allocate-node for an extended explanation of the arguments to node.

    Edit 2019: This answer (and question) was made back in 2017, back then there only was one flavor of Jenkins pipeline, scripted pipeline, since then declarative pipeline has been added. So above answer is true for scripted pipeline, for answers regarding declarative pipeline please see other answers below.

提交回复
热议问题