Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47496

No automatic builds for tags

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Labels:
      None
    • Environment:
      Jenkins 2.73.2, Git Plugin 3.6.0, Pipeline: Multibranch 2.16
    • Similar Issues:

      Description

      After upgrading to the Git Plugin 3.6.0 I activated the "Discover Tags" option in a Multibranch Pipeline Job. The tag is also discovered as expected, but no build is triggered.

       

      Checking tags... 
      Checking tag PNR-12345 
      ‘Jenkinsfile’ found 
      Met criteria 
      Changes detected: PNR-12345 (null → d56c6578f5f04403f4bd64bf2647f3dd0f36e826) 
      No automatic builds for PNR-12345
       Processed 1 tags
      

      I expected that a new build is triggered, when a new tag is found. How to achieve this?

       

        Attachments

          Issue Links

            Activity

            Hide
            stephenconnolly Stephen Connolly added a comment -

            Piotr Sobieszczański So first off we have the Jenkins Queue.

            The queue does not know about multibranch as belonging to a single "project" so instead it sees them all as different jobs. The queue is designed to care about the order within a job but not the order between jobs.

            Each tag gets its own job, thus the tag v1 could be built after the tag v5 even if v1 was put in the queue before v5... there is nothing to do with multibranch, you can get the same effect with regular freestyle jobs

            Next, the tag discovery is not in a deterministic order from git.

            Simple tags do not even have a creation timestamp in the git data model

            Annotated tags do have a creation timestamp, but that does not reflect the push time

            So we have no way to reconstruct the order of simple tags, and we only have a way to reconstruct the creation order of annotated tags... that is not the actual release (i.e. push to canonical repo) order

            Ok, so you might say "well sort the tags"... hmmm except sorting version numbers is a hard problem... does where does RC go w.r.t. alpha, beta, milestone, etc. There are some widely held conventions... but nothing that is a hard and fast rule.

            Finally, if you really want them built on discovery, it's an extension point you can write a plugin that does exactly that and install it... then just configure that option in the build strategies... I just choose not to enable users to easily shoot themselves in the foot... I do not prevent the foot shootings

            Show
            stephenconnolly Stephen Connolly added a comment - Piotr Sobieszczański So first off we have the Jenkins Queue. The queue does not know about multibranch as belonging to a single "project" so instead it sees them all as different jobs. The queue is designed to care about the order within a job but not the order between jobs. Each tag gets its own job, thus the tag v1 could be built after the tag v5 even if v1 was put in the queue before v5 ... there is nothing to do with multibranch, you can get the same effect with regular freestyle jobs Next, the tag discovery is not in a deterministic order from git. Simple tags do not even have a creation timestamp in the git data model Annotated tags do have a creation timestamp, but that does not reflect the push time So we have no way to reconstruct the order of simple tags, and we only have a way to reconstruct the creation order of annotated tags... that is not the actual release (i.e. push to canonical repo) order Ok, so you might say "well sort the tags"... hmmm except sorting version numbers is a hard problem... does where does RC go w.r.t. alpha, beta, milestone, etc. There are some widely held conventions... but nothing that is a hard and fast rule. Finally, if you really want them built on discovery, it's an extension point you can write a plugin that does exactly that and install it... then just configure that option in the build strategies... I just choose not to enable users to easily shoot themselves in the foot... I do not prevent the foot shootings
            Hide
            stephenconnolly Stephen Connolly added a comment -

            Seriously, all you need to do is copy one class and change the logic for automatic build to return head instanceof TagSCMHead; (cf https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/BranchBuildStrategyImpl.java#L55-L64) and then you can shoot your own foot off.

            I will not be adding such an implementation into any plugin I maintain (because I do not want to hear the howls of users on the receiving end of self-foot-shootings) but feel free to roll your own and release it as a plugin to the community (as long as you support the users with the shot feet)

            Show
            stephenconnolly Stephen Connolly added a comment - Seriously, all you need to do is copy one class and change the logic for automatic build to return head instanceof TagSCMHead; (cf https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/BranchBuildStrategyImpl.java#L55-L64 ) and then you can shoot your own foot off. I will not be adding such an implementation into any plugin I maintain (because I do not want to hear the howls of users on the receiving end of self-foot-shootings) but feel free to roll your own and release it as a plugin to the community (as long as you support the users with the shot feet)
            Hide
            sobi3ch Piotr Sobieszczański added a comment -

            Hi Stephen, I understand that tags are not built in order. That obvious. Because I don't care about tags in my project up to now (= until I implement my repository with Jenkins), they can build in whatever order they want (Ideal situation would be if I could mark checkbox with label saying "Do not run old tags, only new one". And yes I understand you can have thousands of tags already, but in real life, you set up repo and then you set up the project with your CI/CD, so you don't have at all, or maybe after some time with maximum several dozens). I just want to build new tags and as you know you don't create several tags per minute. Normally there is one, two maybe three tags per day and that's all. In this situation, you are totally fine with an automatic build. So for instance, you creating a new tag, pushing it to a repo, then Jenkins is detecting it (and this is the only new tag comparing to his repo), and finally triggering it. That's the whole idea.

            Show
            sobi3ch Piotr Sobieszczański added a comment - Hi Stephen, I understand that tags are not built in order. That obvious. Because I don't care about tags in my project up to now (= until I implement my repository with Jenkins), they can build in whatever order they want (Ideal situation would be if I could mark checkbox with label saying "Do not run old tags, only new one". And yes I understand you can have thousands of tags already, but in real life, you set up repo and then you set up the project with your CI/CD, so you don't have at all, or maybe after some time with maximum several dozens). I just want to build new tags and as you know you don't create several tags per minute. Normally there is one, two maybe three tags per day and that's all. In this situation, you are totally fine with an automatic build. So for instance, you creating a new tag, pushing it to a repo, then Jenkins is detecting it (and this is the only new tag comparing to his repo), and finally triggering it. That's the whole idea.
            Hide
            stephenconnolly Stephen Connolly added a comment -

            Piotr Sobieszczański I recommend that you create a plugin with the variation of https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/TagBuildStrategyImpl.java that you need (if the implementation that is already available does not do what you actually need).

            Seriously, how hard is it to install the Basic Branch Build Strategies plugin and then do?

            If you need something for building tags that is different from the one in Basic Branch Build Strategies then it is trivial to create your own.

            But it looks to me like you were not even reading my comments...

            Because I said over a month ago how to build tags automatically... just that it will not exactly meet everyone's requirements because there are cases where building tags could result in build storms and this is why you have to explicitly configure it and decide what risk of build storms you are willing to take

            Show
            stephenconnolly Stephen Connolly added a comment - Piotr Sobieszczański I recommend that you create a plugin with the variation of https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/TagBuildStrategyImpl.java that you need (if the implementation that is already available does not do what you actually need). Seriously, how hard is it to install the Basic Branch Build Strategies plugin and then do? If you need something for building tags that is different from the one in Basic Branch Build Strategies then it is trivial to create your own. But it looks to me like you were not even reading my comments... Because I said over a month ago how to build tags automatically... just that it will not exactly meet everyone's requirements because there are cases where building tags could result in build storms and this is why you have to explicitly configure it and decide what risk of build storms you are willing to take
            Hide
            aarondmarasco_vsi Aaron Marasco added a comment -

            Stephen Connolly thanks for that plug-in; it's exactly what I needed. No more needing checkboxes in my job asking "Do you really mean it?"

            Show
            aarondmarasco_vsi Aaron Marasco added a comment - Stephen Connolly thanks for that plug-in; it's exactly what I needed. No more needing checkboxes in my job asking "Do you really mean it?"

              People

              • Assignee:
                markewaite Mark Waite
                Reporter:
                pmr Philipp Moeller
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: