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

Build strategy for tags is not working, if you specify ignore tags lesser than 7days

      Build strategy for tags is not working, if you specify ignore tags lesser than 7days

      Multibranch pipeline configuration on Automated build tags, Used Build strategy plugin

      Added Tags–> Ignore tags older than as 1 (Events :No automatic build triggered for 1..

      )

      it works only if you specify as 7 days older.(Anything less than 7 is ignoring automated build trigger for tag)

       

      Is this the expected one? shall we have a tags to restrict to build automatically only if that is less than one day too?

          [JENKINS-57772] Build strategy for tags is not working, if you specify ignore tags lesser than 7days

          vinoth SS added a comment -

          markewaite

          i think i guessed it, may be not sure if that is the way this plugin behaves,

           Ignore tags older than   :    how does this work?

          • Created tag less than 7 days?
          • Created tags against Commits less than 7 days?

          Because i tried to create tag which has older commit didnt triggered the build? But if i create a new commit and create tag against that which is triggering the tag job and build...

          So i guess this works against commit id created less than 7 days.? Correct me if my understanding is wrong?

          vinoth SS added a comment - markewaite i think i guessed it, may be not sure if that is the way this plugin behaves,  Ignore tags older than   :     how does this work? Created tag less than 7 days? Created tags against Commits less than 7 days? Because i tried to create tag which has older commit didnt triggered the build? But if i create a new commit and create tag against that which is triggering the tag job and build... So i guess this works against commit id created less than 7 days.? Correct me if my understanding is wrong?

          Mark Waite added a comment -

          Unfortunately, I'm not sure of the precise intent with that strategy, but what you're describing makes sense to me.

          Mark Waite added a comment - Unfortunately, I'm not sure of the precise intent with that strategy, but what you're describing makes sense to me.

          vinoth SS added a comment -

          I guess plugin should work by Date of tags created and not the commit-id created. Let me if this needs to be changed?

          Because in my scenario developers will create tags once all testing is completed and ready for release to production, by that time this does not build because commit id was created long back, but the tag created against commit id is less than 7 days.

          vinoth SS added a comment - I guess plugin should work by Date of tags created and not the commit-id created. Let me if this needs to be changed? Because in my scenario developers will create tags once all testing is completed and ready for release to production, by that time this does not build because commit id was created long back, but the tag created against commit id is less than 7 days.

          Mark Waite added a comment -

          I haven't done the detailed research to confirm it, but my recollection is that there are two types of tags in git, lightweight tags and tag objects. The strategy may be attempting to handle both cases and thus may be assuming in both cases that the date stamp should be taken from the commit that is the target of the tag. I believe that lightweight tags do not include a separate date. If that was the intent, then using the date of the commit associated with the tag may be how it is intended to work.

          Mark Waite added a comment - I haven't done the detailed research to confirm it, but my recollection is that there are two types of tags in git, lightweight tags and tag objects. The strategy may be attempting to handle both cases and thus may be assuming in both cases that the date stamp should be taken from the commit that is the target of the tag. I believe that lightweight tags do not include a separate date. If that was the intent, then using the date of the commit associated with the tag may be how it is intended to work.

          vinoth SS added a comment -

          ok do we have any way to get the actual tags created date stamp? I think to use this plugin that date will be an appropriate one?

          vinoth SS added a comment - ok do we have any way to get the actual tags created date stamp? I think to use this plugin that date will be an appropriate one?

          vinoth SS added a comment - - edited

          i think 

          1. command gives the tag created date 
             
            git for-each-ref --format="%(refname:short) | %(creatordate)" refs/tags/*
          2. Command returns the commit id date for tags

          git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d'
          Not sure which one plugin uses to analyse the date?

           

          vinoth SS added a comment - - edited i think  command gives the tag created date    git for-each-ref --format="%(refname:short) | %(creatordate)" refs/tags/* Command returns the commit id date for tags git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d' Not sure which one plugin uses to analyse the date?  

          Liam Newman added a comment -

          Here is where the plugin tests dates and it uses the "timestamp" of the tag:
          https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/TagBuildStrategyImpl.java#L152

          It is up to the the implementers of TagSCMHead to provide that:
          https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/api/mixin/TagSCMHead.java

          The git plugin does what markewaite described - use the date of tag creation for annotated tags and the date of the last commit for lightweight tags:
          https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java#L37-L38

          This comment on SO repeats what markewaite said:

          There is no date information attached to a lightweight tag. ... The dates in the output of git log --tags --simplify-by-decoration --pretty="format:%ai %d" are the dates of the objects to which the tags point, not the dates when the tags themselves were created.

          I think either of the command above would have this same problem, but you'd need to test them to be sure. Further, it is likely that this behavior will differ depending on the underlying branch source - git, github, bitbucket, etc.

          Liam Newman added a comment - Here is where the plugin tests dates and it uses the "timestamp" of the tag: https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/TagBuildStrategyImpl.java#L152 It is up to the the implementers of TagSCMHead to provide that: https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/api/mixin/TagSCMHead.java The git plugin does what markewaite described - use the date of tag creation for annotated tags and the date of the last commit for lightweight tags: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java#L37-L38 This comment on SO repeats what markewaite said: There is no date information attached to a lightweight tag. ... The dates in the output of git log --tags --simplify-by-decoration --pretty="format:%ai %d" are the dates of the objects to which the tags point, not the dates when the tags themselves were created. I think either of the command above would have this same problem, but you'd need to test them to be sure. Further, it is likely that this behavior will differ depending on the underlying branch source - git, github, bitbucket, etc.

          vinoth SS added a comment -

          it makes sense, I think we need to create annotated tags would actually trigger the job build automatically.

          if people created the lightweight tags, you should note that the tag created date would be last commit date

          Note:  date of tag creation for annotated tags and the date of the last commit for lightweight tags:
          https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java#L37-L38

          vinoth SS added a comment - it makes sense, I think we need to create annotated tags would actually trigger the job build automatically. if people created the lightweight tags, you should note that the tag created date would be last commit date Note:  date of tag creation for annotated tags and the date of the last commit for lightweight tags: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java#L37-L38

          The plugin uses annotated tag's commit timestamp instead of tag created timestamp and use it to compare with the value in the setting "Ignore tags older than".

          Environment:
          Jenkins v2.235.5
          Basic Branch Build Strategies Plugin v1.3.2
          Bitbucket v6.10.0

          To Duplicate this issue,
          1. Set "Ignore tags older than" to 3 and "Ignore tags newer than" to empty string in the project configuration
          2. Create an annotated tag on a commit older than 3 days.
          3. Observe that the tags tab creates a job for the created annotated tag but it doesn't build. It is expected to build, as the tag creation time is less than 3 days and as per the inline help message - "The number of days since the tag was created after which it is no longer eligible for automatic building".
          4. The behavior is same on the annotated tags

          I hope the expected behavior is to consider the tag creation time (not the associated commit time of the tag) for build strategy comparison.

          Shankar Ramasamy added a comment - The plugin uses annotated tag's commit timestamp instead of tag created timestamp and use it to compare with the value in the setting "Ignore tags older than". Environment: Jenkins v2.235.5 Basic Branch Build Strategies Plugin v1.3.2 Bitbucket v6.10.0 To Duplicate this issue, 1. Set "Ignore tags older than" to 3 and "Ignore tags newer than" to empty string in the project configuration 2. Create an annotated tag on a commit older than 3 days. 3. Observe that the tags tab creates a job for the created annotated tag but it doesn't build. It is expected to build, as the tag creation time is less than 3 days and as per the inline help message - "The number of days since the tag was created after which it is no longer eligible for automatic building". 4. The behavior is same on the annotated tags I hope the expected behavior is to consider the tag creation time (not the associated commit time of the tag) for build strategy comparison.

          Rozg Onik added a comment -

          Our systems are also affected by this bug therefore I have managed to do the following investigation:

          As people here pointed out the git plugin should use the tag's creation date in case of an annotated tag as written here: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java#L37-L38

          Problem is I can not find any references to GitTagSCMHead where instantiation happens with the tag's timestamp.
          Instead I only find references where it uses the underlying commit's timestamp:

          So I think the root cause for this issue is the git plugin does not consider using an annotated tag's timestamp to GitTagSCMHead.
          I will open a new issue about that in the git plugin component.

          Environment:
          Jenkins v2.319.3
          Basic Branch Build Strategies Plugin v1.3.2
          Git Plugin v4.10.3

          Rozg Onik added a comment - Our systems are also affected by this bug therefore I have managed to do the following investigation: As people here pointed out the git plugin should use the tag's creation date in case of an annotated tag as written here: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java#L37-L38 Problem is I can not find any references to GitTagSCMHead where instantiation happens with the tag's timestamp. Instead I only find references where it uses the underlying commit's timestamp: https://github.com/jenkinsci/git-plugin/blob/5e7d735c4d24a6e54a7494381a0f6e80dd5f948c/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java#L765 https://github.com/jenkinsci/git-plugin/blob/5e7d735c4d24a6e54a7494381a0f6e80dd5f948c/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java#L990 So I think the root cause for this issue is the git plugin does not consider using an annotated tag's timestamp to GitTagSCMHead. I will open a new issue about that in the git plugin component. Environment: Jenkins v2.319.3 Basic Branch Build Strategies Plugin v1.3.2 Git Plugin v4.10.3

            Unassigned Unassigned
            ss_vinoth22 vinoth SS
            Votes:
            3 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated: