'trigger jenkins build on tag creation with multibranch pipeline

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 :

enter image description here

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?



Solution 1:[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 the building of tags for the pipeline. I did this and now it does build the tags automatically.

Solution 2:[2]

I had a similar despite having the "Basic Branch Build Strategies plugin" plugin installed and having my build strategies and behaviors setup to discover and build tags. The problem ended up being that the commit I tagged was older than the default maximum age of 7 days. Apparently the "age" in this case is related to the commit and not when the tag was created.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mario Apra
Solution 2 kthompso