背景:我们正在寻找关于如何优化我们的管道(以前的工作流程)的解决方案。
目前,我们运行了一些并行部署和测试,这些部署和测试分布在 2 个构建器上,每个构建器有 4 个执行器。
管道由 Git 推送触发,因此后续推送将触发多个构建。我们已经尝试了 stage concurrency: 1 选项,它很好地阻止了后续构建的步骤,但会在该特定阶段完成时启动。
问题:
我不确定这是最佳实践,但在我看来,最好不要执行新构建,直到前一个构建完成。(因为我们已经向它提交了资源,并且应该允许它完成,即使它不是最新和最大的提交)。
Q1:这是最好的做法吗?
Q2:我们如何抢占新的triggert构建,同时仍然运行前一个?(我可以想象迭代这个工作的构建并停止新的......)。
查看第一阶段的配置 [1]
[1] 第一阶段..
stage name: 'Checkout and build WAR'
node {
def mvnHome = tool 'Maven 3.2.x'
checkout([$class : 'GitSCM',
poll : true,
branches : [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions : [[$class : 'RelativeTargetDirectory',
relativeTargetDir: 'checkout-directory']],
submoduleCfg : [],
userRemoteConfigs : [[url: 'https://some.repo/repo.git']]])
// Archive the cloned repo.
stash name: 'src', includes: 'checkout-directory/war/src/, checkout-directory/war/pom.xml'
// Run without tests, do the unit and integration tests in a separate stage.
sh "${mvnHome}/bin/mvn -f checkout-directory clean install -DskipTests"
// Archive the application build.
stash name: 'war', includes: 'checkout-directory/war/target/*.war'
}