Jenkins 管道 - 在循环内按顺序触发作业

Jenkins Pipeline - Trigger jobs sequentially inside a loop

我有一个 Jenkins 管道,我在其中触发具有不同参数的单个作业。参数的数量也可能会改变,这会改变作业需要触发的次数。这就是为什么我在 for 循环中使用 build job 的原因。代码如下所示:

pipeline{

    stages{
        stage('Setup'){
            steps{
                script {
                    for (int i=0; i<list_one.size(); i++ ) {
                    def index_i = i
                        for (int j=0; j<list_two.size(); j++) {
                            def index_j = j
                            stage ("${list_one[i]} ${list_two[j]}") {
                                sh "echo 'index_i: ${index_i}'"
                                sh "echo 'index_j: ${index_j}'"
                                build job: 'Downstream Job', parameters: [
                                    string(name: 'some_param', value: "${list_one[index_i]}")]
                            }
                        }
                    }
                }
            }
        }
    }
}

当我 运行 这个管道时,它只 运行 一次用于两个循环的第一次迭代。但是,当我删除 build job 行时,列表中所有值的管道 运行s。我对为什么会这样感到困惑,并希望在这件事上得到一些帮助。

或者你可以使用像 propagate=false 这样的东西。

Is there a way to use "propagate=false" in a Jenkinsfile with declarative syntax directly for stage/step?