Jenkins - 为特定工作保留构建

问题描述 投票:0回答:1

我很少有詹金斯工作会触发验收测试。此时 AT 配置为运行 5 个并发构建:

  throttleJobProperty(
            maxConcurrentPerNode: 0,
            maxConcurrentTotal: 5,
            paramsToUseForLimit: '',
            throttleEnabled: true,
            throttleOption: 'project'
        )

我希望始终为特定下游触发器保留 1 个构建。因此,如果 job2/job3/job4/jobN 触发 AT,我希望能够运行通过 job1 触发的 AT,而无需在队列中等待。这有可能吗?如果没有的话,类似的配置可以实现吗?

jenkins jenkins-pipeline jenkins-plugins
1个回答
0
投票

在Jenkins中,您配置的throttleJobProperty用于限制特定作业的并发构建数量。但是,它没有提供为特定下游触发器保留时隙的直接方法。

这是使用脚本化管道的简化示例:

if (currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause)) { def uploadCause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) def 上游作业名称 = 上游原因.upstreamProject

if (upstreamJobName == 'job1') {
    // Don't apply throttling for job1
} else {
    throttleJobProperty(
        maxConcurrentPerNode: 0,
        maxConcurrentTotal: 5,
        paramsToUseForLimit: '',
        throttleEnabled: true,
        throttleOption: 'project'
    )
}

}

// 用于验收测试的其余管道步骤

© www.soinside.com 2019 - 2024. All rights reserved.