Skip to content

Instantly share code, notes, and snippets.

@bbeck
Last active January 19, 2018 00:17
Show Gist options
  • Save bbeck/f9f159802242c55d3e9e37ddfabaaa46 to your computer and use it in GitHub Desktop.
Save bbeck/f9f159802242c55d3e9e37ddfabaaa46 to your computer and use it in GitHub Desktop.
Jenkins milestone issue

Pipeline #1

stage("build") {
  echo "in build"
}

stage("deploy to prod") {
  input message: "Deploy to prod?"
  milestone(ordinal: 20, label: "prod")
  echo "deploying to prod"
}

Pipeline #2

stage("build") {
  echo "in build"
}

stage("deploy to test") {
  milestone(ordinal: 10, label: "test")
  echo "deploying to test"
}

stage("deploy to prod") {
  input message: "Deploy to prod?"
  milestone(ordinal: 20, label: "prod")
  echo "deploying to prod"
}
@bbeck
Copy link
Author

bbeck commented Jan 18, 2018

After creating a pipeline job with Pipeline #1 and starting 3 invocations Jenkins looks like this:

image

Next, abort build #2 and then Jenkins looks like this:

image

This all looks correct. Next I proceed build #3 and then Jenkins looks like this:

image

This also seems correct. Build #1 looks like it's still running, but as soon as the input releases control it will either terminate with an exception (the user hit "Abort") or terminate because it's been superseded by #3 which has hit the milestone. Everything operating as expected here.

@bbeck
Copy link
Author

bbeck commented Jan 19, 2018

After creating a pipeline job with Pipeline #2 and starting 3 invocations, Jenkins looks like this:

image

Also, going to the script console and executing this code:

import org.jenkinsci.plugins.pipeline.milestone.*
println Jenkins.instance.getDescriptor(MilestoneStep.class).getMilestonesByOrdinalByJob()

Produces this output:

[milestone-test-2:[10:Milestone[inSight=[1, 2, 3]]]]

This shows all 3 builds having hit the milestone.

Next, if I abort build #2 then Jenkins looks like this:

image

It doesn't seem like consistent behavior with the first pipeline I showed, or even correct behavior for Build #1 to be aborted after aborting Build #2.

Am I misunderstanding something, or is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment