我有多个带有“build_run”标签的节点(例如;node1、node2、node3)。因此,当我运行此管道时,我无法确定“构建”和“运行”作业是否在同一节点中运行。“构建”可以发生在“节点 1”中,“运行”可以发生在“节点 3”中。我希望 Build 和 run 都发生在同一个节点上。但我不想硬编码相同。我想知道哪个节点被“Build”选中。这样我就可以将它作为节点参数传递给 Run。我该如何解决这个问题?
stage('Build, run) {
for(int i=0; i<4; ++i){
def builds = {
stage('Build') {
build job: 'Build', parameters: [[$class: 'LabelParameterValue', name: 'TestMachine', label: 'build_run']]
}
stage('Run') {
build job: 'Run', parameters: [[$class: 'LabelParameterValue', name: 'TestMachine', label: 'build_run']]
}
}
}
}
parallel builds
我使用了类似下面的东西,它对我有用。(使用 rawBuild.getEnvironment()['NODE_NAME'] 获取运行作业的节点。)
def node_to_use = ""
stage('Build, run) {
for(int i=0; i<4; ++i){
def builds = {
stage('Build') {
def build_var = build job: 'Build', parameters: [[$class: 'LabelParameterValue', name: 'TestMachine', label: 'build_run']]
node_to_use = build_var.rawBuild.getEnvironment()['NODE_NAME']
}
stage('Run') {
build job: 'Run', parameters: [[$class: 'LabelParameterValue', name: 'TestMachine', label: node_to_use]]
}
}
}
}
parallel builds
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句