gpt4 book ai didi

jenkins - 禁用并发构建

转载 作者:行者123 更新时间:2023-12-04 20:35:22 35 4
gpt4 key购买 nike

背景 :我们正在寻找有关如何优化我们的管道(以前的工作流程)的解决方案。

目前,我们运行了一些并行部署和测试,这些部署和测试分布在 2 个构建器上,每个构建器有 4 个执行器。

管道由 Git 推送触发,因此后续推送将触发多个构建。我们已经试验了阶段并发:1 选项,它很好地阻止了后续构建的一个步骤,但会在该特定阶段完成时启动。

问题 :

我不确定这是最佳实践,但在我看来,最好不要执行新构建,直到前一个完成。 (这是因为我们已经向它提交了资源,并且应该允许它完成,即使它不是最新和最大的提交)。

Q1:这是最好的做法吗?

Q2:我们如何抢占新的触发器构建,同时仍然运行前一个? (我可以想象遍历这项工作的构建并停止新工作......)。

见第一阶段的配置[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'
}

最佳答案

来自工作的 configuration你可以设置:

  • 如有必要,执行并发构建
  • 安静期

  • If set, a newly scheduled build waits for this many seconds before actually being built. This is useful for:

    • Collapsing multiple CVS change notification e-mails into one (some CVS changelog e-mail generation scripts generate multiple e-mails in quick succession when a commit spans across directories).
    • If your coding style is such that you commit one logical change in a few cvs/svn operations, then setting a longer quiet period would prevent Jenkins from building it prematurely and reporting a failure.
    • Throttling builds. If your Jenkins installation is too busy with too many builds, setting a longer quiet period can reduce the number of builds.

    If not explicitly set at project-level, the system-wide default value is used.



    至于 jenkins-pipeline DSL 此 article回答你的问题:

    By default, Pipeline builds can run concurrently. The stage command lets you mark certain sections of a build as being constrained by limited concurrency (or, later, unconstrained). Newer builds are always given priority when entering such a throttled stage; older builds will simply exit early if they are preëmpted.

    关于jenkins - 禁用并发构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36747580/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com