Jenkins 多分支管道不安排标记作业

Jenkins Multi-branch pipeline doesn't schedule tag jobs

我正在尝试让 Jenkins 的多分支管道作业以类似于分支的方式构建标签。在 Jenkins 2.73(不确定何时添加该功能)中,可以配置多分支项目以从源存储库中检索分支和标签。最初我认为这将非常适合我的需求(我的 Jenkinsfile 现在可以在 Jenkins 的同一个地方构建开发或生产版本)。 Multibranch job with tags discovery configured

我已经启动了构建过程,并且 运行 非常高兴地使用脚本管道,但是我的问题是,虽然分支作业完美地拾取了我的触发器(Cron 每周一次),因此可以使用 Git 插件的 notifyOnCommit 功能(允许我每周清理构建,但也通过 repo 扫描 webhook 对 repo 进行构建),标签构建没有。

还有其他人遇到过这个吗?如果有,你有没有找到合理的解决办法?

我的脚本管道中的相关片段(我尝试使用和不使用 overrideIndexTriggers 设置):

properties(
  [
    pipelineTriggers(
      triggers: [
        cron('H 02 * * 7')
      ]
    ),
    overrideIndexTriggers(true)
  ]
)

Polling configuration from a branch job generated by the multibranch pipeline seems fine 多分支管道从标签生成的作业没有收到相同的配置,很奇怪...

多分支管道扫描日志中有一条注释表明永远不会自动安排标签:

Processed 8 branches
Checking tags...
  Checking tag testing
      ‘Jenkinsfile’ found
    Met criteria
No automatic builds for testing
Processed 1 tags
[Mon Oct 23 09:55:00 UTC 2017] Finished branch indexing. Indexing took 8.1 sec
Finished: SUCCESS

我的项目是基于 docker 的,我想 运行 每周发布一次构建,以引入任何基础映像更改等。

有人知道我可以做些什么来让多分支项目安排标签构建吗?

根据JENKINS-47496,似乎是设计使然不会自动触发已发现标签的构建。 Stephen Connolly 对您可能会做的事情提供了解释和建议:

Stephen Connolly added a comment - 6 days ago

Tags are not built by default (because otherwise you could have a build storm when checking out a repository) and worse, the order tags will be built in is unpredictable... and you might have a Jenkinsfile that deploys to production when a tag is built.

There is an extension point in branch-api called BranchBuildStrategy which - if implemented - will allow deciding whether to build tags.

See https://github.com/jenkinsci/github-branch-source-plugin/pull/158#issuecomment-332773194 for starting point on how to create such an extension plugin... I believe there is some work on one at https://github.com/AngryBytes/jenkins-build-everything-strategy-plugin