jenkins - 脚本化的 Jenkinsfile 并行构建器不起作用
问题描述
我正在尝试在我的脚本 jenkinsfile 中使用并行构建器。当我运行代码时,詹金斯忽略了节点标签,只选择了第一个可用的标签。我究竟做错了什么?
这是代码:
node {
withCredentials([
string(credentialsId: 'some ID', variable: 'some variable')
]) {
stage('Initialize') {
setup()
}
}
}
}
def setup_worker() {
def labels = ['label2', 'label1']
def builders = [:]
for (x in labels) {
def label = x
builders[label] = {
node(label) {
stage('Setup') {
step1
checkout scm
login()
write_config()
}
}
}
}
parallel builders
}```
解决方案
我强烈建议使用 Jenkins 声明式管道来处理不同节点上的并行阶段。语法更简单且有据可查
推荐阅读
- python - 如何清除除标签以外的所有小部件
- php - 如何在 index.php 中使用 is_archive() 来检索 WordPress 中基于存档的特定模板?
- r - 为什么我在 glmmTMB 的输出中看不到所有类别的解释变量?
- mysql - 如何按范围选择包含数字的行?
- database - 重构基于事件的数据以便于查询
- python - python中的一个大if ... elif我想在一行中改进
- javascript - 如何制作用于单击网页上的按钮的脚本?
- api - 如何在 infobip 上个性化电子邮件
- tensorflow - Keras Upsampling2d -> tflite 转换导致形状推断失败和未定义的输出形状
- c++ - 无法从“<brace-enclosed initializer list>”转换为向量