触发jenkins使用多分支管道在标签创建上进行构建 [英] trigger jenkins build on tag creation with multibranch pipeline

查看:418
本文介绍了触发jenkins使用多分支管道在标签创建上进行构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Jenkinsfile 中处于一个阶段从与标签名称过滤器匹配的标签中构建:

I've got a stage in my Jenkinsfile for building from a tag matching a tag name filter:

      stage('Build Release from Tag') {
        when {
          tag '*RELEASE'
        }

为了使标签被发现,我必须添加标签发现和标签名称regex的匹配项,并添加到Branch sources > GitHub下的管道中:

In order to get tags to be discovered I've had to add tag discovery and a match for the tag name regex and to my pipeline under Branch sources > GitHub :

管道会发现我推送的与过滤器匹配的标签.如果我单击一个为其运行构建,则它会运行与条件标签匹配的构建阶段.但是我期待的是基于我对博客文章的解释,该构建将像分支的构建一样自动开始.

The pipeline does discover tags that I push which match the filter. And if I click on one to run a build for it then it does run the build stage that matches the tag conditional. But I was expecting, based on my interpretation of a blogpost, that the build would start automatically as build for branches do.

在扫描存储库日志中,我看到如下输出:

In the scan repository log I see output such as:

    Checking tag TEST0.1.3.RELEASE
      ‘Jenkinsfile’ found
    Met criteria
Changes detected: TEST0.1.3.RELEASE (null → 4aea4ec43c1daf8290ea438ce0bf1a14a6afbc46)
No automatic builds for TEST0.1.3.RELEASE

我还在repository events日志中看到了输出,例如Received Push event for tag TEST.0.1.8.RELEASE in repository ryandawsonuk/activiti-build CREATED event,因此Jenkins知道正在创建的标签. (我想我已经知道了,因为它会发现它们并在UI中显示它们,除非我手动触发构建,否则它不会构建它们.)

I also see output in the repository events log such as Received Push event for tag TEST.0.1.8.RELEASE in repository ryandawsonuk/activiti-build CREATED event so Jenkins is aware of tags being created. (Which I guess I know already because it discovers them and shows them in the UI, it just doesn't build them unless I manually trigger the build.)

我应该说我正在使用Jenkins-X.据我所知,这是一个詹金斯问题,与Jenkins-X无关,但我可能忽略了某些事情.

I should say I am using Jenkins-X. As far as I can see this is a Jenkins question and doesn't relate to anything specific to Jenkins-X but I could be overlooking something.

如果管道应在创建标签时自动触发(似乎Jenkins支持但我'不是100%确信),那么我想知道可以添加哪些其他配置来自动触发构建?

If the pipeline should trigger automatically on tag creation (it seems like Jenkins supports that but I'm not 100% sure) then I'm wondering what additional configuration I could add to trigger the build automatically?

推荐答案

我只需要阅读 https://issues.jenkins-ci.org/browse/JENKINS-47496 更加紧密.默认情况下,标记不会自动构建.您必须安装Basic Branch Build Strategies plugin并激活管道标记的构建.我这样做了,现在它会自动构建标签.

I just needed to read https://issues.jenkins-ci.org/browse/JENKINS-47496 more closely. Tags aren't built automatically by default. You have to install the Basic Branch Build Strategies plugin and activate building of tags for the pipeline. I did this and now it does build the tags automatically.

这篇关于触发jenkins使用多分支管道在标签创建上进行构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆