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

          Activity

          Hide
          markewaite Mark Waite added a comment - - edited

          I am unable to duplicate the problem that you are describing. Please provide instructions to create the job which is showing the failure.

          Steps I took attempting to show the failure:

          1. Create a multibranch Pipeline job using the GitHub branch source
          2. Disable all default behaviors (no branch discovery, no pull request discovery)
          3. Add the "Discover tags" behavior
          4. Add the build strategy "Tags" with an empty value for Ignore tags newer than
          5. Change the "Tags" build strategy Ignore tags older than from its default 7 to 1
          6. Run the job, confirm that it selected no tags to be built and no branches to be built (because there have been no tags created on that repository in the last 1 day)

          The job definition I used is uploaded as config.xml

          Show
          markewaite Mark Waite added a comment - - edited I am unable to duplicate the problem that you are describing. Please provide instructions to create the job which is showing the failure. Steps I took attempting to show the failure: Create a multibranch Pipeline job using the GitHub branch source Disable all default behaviors (no branch discovery, no pull request discovery) Add the "Discover tags" behavior Add the build strategy "Tags" with an empty value for Ignore tags newer than Change the "Tags" build strategy Ignore tags older than from its default 7 to 1 Run the job, confirm that it selected no tags to be built and no branches to be built (because there have been no tags created on that repository in the last 1 day) The job definition I used is uploaded as config.xml
          Hide
          ss_vinoth22 vinoth SS added a comment -

          when you scan it is not detected tags less than 1 day, but can u create a new tag , It is detected but not triggered automated build.

          Show
          ss_vinoth22 vinoth SS added a comment - when you scan it is not detected tags less than 1 day, but can u create a new tag , It is detected but not triggered automated build.
          Hide
          markewaite Mark Waite added a comment -

          I'm not sure I understand your statement.

          I added a new tag called 'temp-tag-a' and then clicked the link to scan the repository. The new tag was detected by the scan and a new build was scheduled.

          I removed the new tag called 'temp-tag-a' and then clicked the link to scan the repository. The deletion of the tag was detected and the job for temp-tag-a was deleted.

          Please provide numbered steps to recreate the problem you are seeing. Others cannot help you if they cannot duplicate the problem you're seeing.

          Show
          markewaite Mark Waite added a comment - I'm not sure I understand your statement. I added a new tag called 'temp-tag-a' and then clicked the link to scan the repository. The new tag was detected by the scan and a new build was scheduled. I removed the new tag called 'temp-tag-a' and then clicked the link to scan the repository. The deletion of the tag was detected and the job for temp-tag-a was deleted. Please provide numbered steps to recreate the problem you are seeing. Others cannot help you if they cannot duplicate the problem you're seeing.
          Hide
          ss_vinoth22 vinoth SS added a comment - - edited

          Mark Waite

          Steps i tried :

          1. Add the "Discover tags" behavior in multibranch pipeline
          2. Add the build strategy "Tags" with an empty value for Ignore tags newer than
          3. Change the "Tags" build strategy Ignore tags older than from its default 7  to 1
          4.  i have created tags, when you manually scan the organization folder again it is working, but not automatically scanning the events and running the tag job is not happening.
          5. Automated tag job and build ran successfully if you have   Ignore tags older than as its default 7. Then whenever you create tags in Bitbucket , Jenkins events scans automatically and trigger the build as well.

           

          hope this is clear...Let me know if im doing anything wrong. Thanks in advance.

          Show
          ss_vinoth22 vinoth SS added a comment - - edited Mark Waite Steps i tried : Add the "Discover tags" behavior in multibranch pipeline Add the build strategy "Tags" with an empty value for  Ignore tags newer than Change the "Tags" build strategy  Ignore tags older than  from its default 7  to 1  i have created tags, when you manually scan the organization folder again it is working, but not automatically scanning the events and running the tag job is not happening. Automated tag job and build ran successfully if you have    Ignore tags older than as  its default 7. Then whenever you create tags in Bitbucket , Jenkins events scans automatically and trigger the build as well.   hope this is clear...Let me know if im doing anything wrong. Thanks in advance.
          Hide
          markewaite Mark Waite added a comment -

          vinoth SS can you also provide the config.xml file from the job that you defined? That will allow comparison with the configuration I'm using successfully.

          When you say:

          not automatically scanning the events and running the tag job is not happening

          I think you mean that the Bitbucket webhook which was registered by the multibranch pipeline is not causing the job to run when a tag is created and pushed to the repository. Is that correct? Were there any other changes pushed to the Bitbucket repository in that time? If the Ignore tags older than is set to 2 instead of 1. does it still behave badly?

          Show
          markewaite Mark Waite added a comment - vinoth SS can you also provide the config.xml file from the job that you defined? That will allow comparison with the configuration I'm using successfully. When you say: not automatically scanning the events and running the tag job is not happening I think you mean that the Bitbucket webhook which was registered by the multibranch pipeline is not causing the job to run when a tag is created and pushed to the repository. Is that correct? Were there any other changes pushed to the Bitbucket repository in that time? If the Ignore tags older than is set to 2 instead of 1 . does it still behave badly?
          Hide
          ss_vinoth22 vinoth SS added a comment - - edited

          Mark Waite

          When you say:

          not automatically scanning the events and running the tag job is not happening

          I think you mean that the Bitbucket webhook which was registered by the multibranch pipeline is not causing the job to run when a tag is created and pushed to the repository. Is that correct? Were there any other changes pushed to the Bitbucket repository in that time? If the Ignore tags older than is set to 2 instead of 1. does it still behave badly?

           

          Yes exactly!! when you create multibranch pipeline is not causing the job to create and run... and there was no other changes has pushed at that time.

          If the Ignore tags older than is set to 2 instead of 1

          yes it works only when i enter 7, i tried all number from 1-6... It didnt causing the job to run.

          Please find the config file attached

          config.xml

          Show
          ss_vinoth22 vinoth SS added a comment - - edited Mark Waite When you say: not automatically scanning the events and running the tag job is not happening I think you mean that the Bitbucket webhook which was registered by the multibranch pipeline is not causing the job to run when a tag is created and pushed to the repository. Is that correct? Were there any other changes pushed to the Bitbucket repository in that time? If the  Ignore tags older than  is set to  2  instead of  1 . does it still behave badly?   Yes exactly!! when you create multibranch pipeline is not causing the job to create and run... and there was no other changes has pushed at that time. If the  Ignore tags older than  is set to  2  instead of  1 yes it works only when i enter 7, i tried all number from 1-6... It didnt causing the job to run. Please find the config file attached config.xml
          Hide
          ss_vinoth22 vinoth SS added a comment -

          Mark Waite

          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?

          Show
          ss_vinoth22 vinoth SS added a comment - Mark Waite 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?
          Hide
          markewaite 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.

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

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