跳至主要内容

博文

目前显示的是 六月, 2024的博文

In a declarative jenkins pipeline - can I set the agent label dynamically?

原文链接 To see how this works, use a GString object to do a println and return the variable for the agentName at the same time. You can see from the output that this line evaluates well before any of the other pipeline code. agentName = "Windows" agentLabel = "${println 'Right Now the Agent Name is ' + agentName; return agentName}" pipeline { agent none stages { stage('Prep') { steps { script { agentName = "Linux" } } } stage('Checking') { steps { script { println agentLabel println agentName } } } stage('Final') { agent { label agentLabel } steps { script { println agentLabel println agentName } } ...