trigger jenkins build on tag creation with multibranch pipeline

霸气de小男生 提交于 2020-04-10 14:28:20

问题


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'
        }

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

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.)

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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/52404216/trigger-jenkins-build-on-tag-creation-with-multibranch-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!