gpt4 book ai didi

jenkins - "Build Periodically"在 Jenkins 中具有多分支管道

转载 作者:行者123 更新时间:2023-12-02 11:51:55 25 4
gpt4 key购买 nike

我正在使用 Pipeline 插件运行 Jenkins 2。我已经设置了一个多分支管道项目,其中每个分支(主分支、开发分支等)的根目录中都有一个 Jenkinsfile。设置起来很简单。但是,即使代码没有更改,我也不知道如何让每个分支定期运行(而不是分支索引)。我需要在 Jenkinsfile 中添加哪些内容才能启用定期构建?

最佳答案

如果您使用声明式风格的 Pipeline 并且只想在特定分支上触发构建,您可以执行以下操作:

String cron_string = BRANCH_NAME == "master" ? "@hourly" : ""

pipeline {
agent none
triggers { cron(cron_string) }
stages {
// do something
}
}

发现于Jenkins Jira

关于jenkins - "Build Periodically"在 Jenkins 中具有多分支管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39168861/

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