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

    Details

    • Similar Issues:

      Description

      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?

        Attachments

        1. config.xml
          4 kB
          vinoth SS
        2. config.xml
          4 kB
          Mark Waite
        3. Screen Shot 2019-05-31 at 9.00.22.png
          90 kB
          vinoth SS
        4. Screen Shot 2019-05-31 at 9.09.23.png
          21 kB
          vinoth SS

          Activity

          Hide
          markewaite 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.

          Show
          markewaite 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.
          Hide
          ss_vinoth22 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?

          Show
          ss_vinoth22 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?
          Hide
          ss_vinoth22 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?

           

          Show
          ss_vinoth22 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?  
          Hide
          bitwiseman 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 Mark Waite 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 Mark Waite 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.

          Show
          bitwiseman 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 Mark Waite 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 Mark Waite 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.
          Hide
          ss_vinoth22 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

          Show
          ss_vinoth22 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

            People

            • Assignee:
              Unassigned
              Reporter:
              ss_vinoth22 vinoth SS
            • Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated: