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

Milestone step fails to pass due to deleted/future builds having passed

      23:35:58 Trying to pass milestone 0
      23:35:58 Canceled since build #6 already got here
      [Pipeline] }

      But this is build #4 - which is the latest build! The newer builds have been deleted. So the milestone step plugin should consider what is the latest currently available build - not the highest number in history.

          [JENKINS-38641] Milestone step fails to pass due to deleted/future builds having passed

          Simon Norra added a comment -

          I did face a very similar issue.

          In our project we create pipeline jobs per branch with Job DSL for a lot of microservice projects. We are using the milestone plugin as well and were very happy with this. Accidentally a change to our Job DSL script caused the seed job to delete all pipeline jobs. After fixing the issue the jobs were created again, causing all jobs to fail, because they were going to start at build number 1.

          The output looks like this

          [Pipeline] milestone
          Trying to pass milestone 1
          Canceled since build #6 already got here
          [Pipeline] End of Pipeline
          

          To reproduce this:

          • Create a job named "test-pipeline"
          • add:
            stage "BUILD"
            
            echo "I do something"
            
            stage "RELEASE"
            
            milestone 1
            input message: 'Do you want to release me?', ok: 'Go, release, go!'
            milestone 2
            
            echo "Yes, I am released!"
            
          • Just try the job a few times and accept the input prompt
          • The milestone plugin behaves as expected
          • Now delete the job
          • Now create the job again, with exactly the same name and pipeline DSL script
          • Start the job
          • Now the job fails because the build counter is not reset and the job "thinks" the build is older than a previous one of the first, deleted job

          This currently makes the usage of the milestone plugin useless for us. Or is there anything we can do about it?

          Thank you

          Simon Norra added a comment - I did face a very similar issue. In our project we create pipeline jobs per branch with Job DSL for a lot of microservice projects. We are using the milestone plugin as well and were very happy with this. Accidentally a change to our Job DSL script caused the seed job to delete all pipeline jobs. After fixing the issue the jobs were created again, causing all jobs to fail, because they were going to start at build number 1. The output looks like this [Pipeline] milestone Trying to pass milestone 1 Canceled since build #6 already got here [Pipeline] End of Pipeline To reproduce this: Create a job named "test-pipeline" add: stage "BUILD" echo "I do something" stage "RELEASE" milestone 1 input message: 'Do you want to release me?' , ok: 'Go, release, go!' milestone 2 echo "Yes, I am released!" Just try the job a few times and accept the input prompt The milestone plugin behaves as expected Now delete the job Now create the job again, with exactly the same name and pipeline DSL script Start the job Now the job fails because the build counter is not reset and the job "thinks" the build is older than a previous one of the first, deleted job This currently makes the usage of the milestone plugin useless for us. Or is there anything we can do about it? Thank you

          I too just ran into this bug. We deleted a job to clear out old history, recreated it and all of our builds now fail because of milestones on an old version.

          I highly disagree with the milestone data surviving deletion of the entire job. Given the current architecture, if I ever delete a job that uses milestones than that job name is forever unusable on that server. That seems highly undesirable to me.

          Matthew Douglass added a comment - I too just ran into this bug. We deleted a job to clear out old history, recreated it and all of our builds now fail because of milestones on an old version. I highly disagree with the milestone data surviving deletion of the entire job. Given the current architecture, if I ever delete a job that uses milestones than that job name is forever unusable on that server. That seems highly undesirable to me.

          Ok. If this is happening when a job is deleted and recreated for some reason (intead of deleting builds), then looks like a valid bug.

          A JobListener has to be added to monitor job deletions so the internal status tracking file can be updated accordingly.

          Antonio Muñiz added a comment - Ok. If this is happening when a job is deleted and recreated for some reason (intead of deleting builds), then looks like a valid bug. A JobListener has to be added to monitor job deletions so the internal status tracking file can be updated accordingly.

          Downgrading to major as remove/readd a job with the same name is not a frequent task in a production environment.

          BTW the workaround (ugly but a workaround) is to edit the file JENKINS_HOME/org.jenkinsci.plugins.pipeline.milestone.MilestoneStep.xml and remove the entry element about the removed job (the job name is in //entry/string). It will be regenerated automatically after the first run of the new job.

          Antonio Muñiz added a comment - Downgrading to major as remove/readd a job with the same name is not a frequent task in a production environment. BTW the workaround (ugly but a workaround) is to edit the file JENKINS_HOME/org.jenkinsci.plugins.pipeline.milestone.MilestoneStep.xml and remove the entry element about the removed job (the job name is in //entry/string ). It will be regenerated automatically after the first run of the new job.

          Code changed in jenkins
          User: Antonio Muñiz
          Path:
          .gitignore
          src/main/java/org/jenkinsci/plugins/pipeline/milestone/MilestoneStepExecution.java
          src/test/java/org/jenkinsci/plugins/pipeline/milestone/CleaupJobsTest.java
          http://jenkins-ci.org/commit/pipeline-milestone-step-plugin/b9fedb94930868b19987f3acb42d3e1030f11bb3
          Log:
          JENKINS-38641 Clean up tracked jobs on deleted

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Antonio Muñiz Path: .gitignore src/main/java/org/jenkinsci/plugins/pipeline/milestone/MilestoneStepExecution.java src/test/java/org/jenkinsci/plugins/pipeline/milestone/CleaupJobsTest.java http://jenkins-ci.org/commit/pipeline-milestone-step-plugin/b9fedb94930868b19987f3acb42d3e1030f11bb3 Log: JENKINS-38641 Clean up tracked jobs on deleted

          Code changed in jenkins
          User: Antonio Muniz
          Path:
          http://jenkins-ci.org/commit/pipeline-milestone-step-plugin/9826f7a8996a54c5fe6fbb7ee5414fe9dc2cd673
          Log:
          Merge branch 'master' into JENKINS-38641

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Antonio Muniz Path: http://jenkins-ci.org/commit/pipeline-milestone-step-plugin/9826f7a8996a54c5fe6fbb7ee5414fe9dc2cd673 Log: Merge branch 'master' into JENKINS-38641

          Code changed in jenkins
          User: Antonio Muniz
          Path:
          .gitignore
          src/main/java/org/jenkinsci/plugins/pipeline/milestone/MilestoneStepExecution.java
          src/test/java/org/jenkinsci/plugins/pipeline/milestone/CleaupJobsTest.java
          http://jenkins-ci.org/commit/pipeline-milestone-step-plugin/a0434815e3d37cfce9ced2ee97b957cf650017f4
          Log:
          Merge pull request #6 from amuniz/JENKINS-38641

          [FIX JENKINS-38641] Clean up tracked jobs on deleted

          Compare: https://github.com/jenkinsci/pipeline-milestone-step-plugin/compare/5077e3a1200b...a0434815e3d3

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Antonio Muniz Path: .gitignore src/main/java/org/jenkinsci/plugins/pipeline/milestone/MilestoneStepExecution.java src/test/java/org/jenkinsci/plugins/pipeline/milestone/CleaupJobsTest.java http://jenkins-ci.org/commit/pipeline-milestone-step-plugin/a0434815e3d37cfce9ced2ee97b957cf650017f4 Log: Merge pull request #6 from amuniz/ JENKINS-38641 [FIX JENKINS-38641] Clean up tracked jobs on deleted Compare: https://github.com/jenkinsci/pipeline-milestone-step-plugin/compare/5077e3a1200b...a0434815e3d3

          Ryan Newsom added a comment -

          hmm running into this right now. What version was this fixed in?

          Ryan Newsom added a comment - hmm running into this right now. What version was this fixed in?

          amuniz Could you please release the plugins version that include this fix?

          The last version, 1.3.1 is 2 years old.

          Pascal Laporte added a comment - amuniz Could you please release the plugins version that include this fix? The last version, 1.3.1 is 2 years old.

          We have the same problems. We had to delete many jobs and recreate them again.

          And now we the same situation when builds are being aborted.

          When are you going release fixed version?

          Gregory Danenberg added a comment - We have the same problems. We had to delete many jobs and recreate them again. And now we the same situation when builds are being aborted. When are you going release fixed version?

            amuniz Antonio Muñiz
            davidkarlsen davidkarlsen
            Votes:
            4 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: