properties({}) | 修改构建的配置
properties: Set job properties | https://www.jenkins.io/doc/pipeline/steps/workflow-multibranch/#-properties-%20set%20job%20properties
https://stackoverflow.com/questions/44113834/trigger-hourly-build-from-scripted-jenkinsfile
properties( [ ... , // other properties that you have pipelineTriggers([cron('0 * * * *')]), ] )
场景 | 触发构建 | 针对分支 | Branch
Jenkins 2.469 | GitLab 16.5
通过 GitLab 触发 Multibranch Pipeline 构建。针对自动化触发,需要 GitLab Plugin 插件。https://plugins.jenkins.io/gitlab-plugin/
第一步、创建多分支流水
当创建 Job 实例时,选择 Multibranch Pipeline 即可,具体细节不再展开。
Pipeline: Multibranch | https://plugins.jenkins.io/workflow-multibranch/
第二步、配置自动化触发
在 GitLab 中,选择项目,Settings,Webhooks,Add new webhook
补充说明
针对 Multibranch Pipeline 场景,Manage Jenkins,GitLab,取消`Enable authentication for ‘/project’ end-point`选项,似乎并不能关闭认证。
场景 | 触发构建 | 针对标签 | Tag
In Jenkins, does a multibranch pipeline support Git tags? – Stack Overflow
When using tags in Jenkins Pipeline
在 Multibranch Pipeline 中,配置 Discover tags 参数,能够实现 Tag 自动发现。
但是,需要手动进行构建,暂时(09/10/2024,)无法自动触发。参考 [JENKINS-47496] No automatic builds for tags#comment-317789 的解释,其大致意思是:如果存在较多 Tag,那么首次触发将导致多个构建。
场景 | 放弃构建 | 第一次构建
首次创建 Pipeline 时,如果多个分支都包含 Jenkinsfile 文件,则会触发多个构建。
我们希望能够放弃首次构建。
# 09/10/2024 | 放弃首次构建是一种解决方案。还有其他方案,例如,分析问题的发生场景,或许我们并不需要处理该问题。
# 04/24/2025 | Pipeline: Multibranch Version 803.v08103b_87c280 | 在 Branch Source 中,添加 Git 仓库,Property strategy,Add property
- Branch names to build automatically: ^$
- Suppression strategy: For matching branches schedule all builds (nothing is suppressed)