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

Stage result not always considered for stage post action



    • Bug
    • Resolution: Duplicate
    • Critical
    • pipeline
    • Jenkins 2.319.1, Windows 10


      I noticed a strange behavior when using post actions for stages. It seems like the stage result for a post action is not considered if there is already a worse overall build result set.

      According to the doc, the post success block should:

      Only run the steps in post if the current Pipeline's or stage's run has a "success" status, typically denoted by blue or green in the web UI.

      It rather looks like that it only runs the steps if the current pipeline status is SUCCESS or not set and the stage is also SUCCESS. If the stage is SUCCESS but not the pipeline status it would not be executed.

      This seems very unintuitive because you would think that if a stage is successful, the success stage post action would also always be triggered. Therefore, the post actions for steps is actually not usable if the overall build result is set to e.g., UNSTABLE.


      I added a small example where such a behavior can be seen:

      pipeline {
          agent any
          stages {
              stage ('A') {
                  steps {
                      unstable('Step unstable')
              stage ('B') {
                  steps {
                      echo('Step B')
                  post {
                      success {
                          echo "Success B!"
                      unstable {
                          echo "Unstable B!"

      Stage A is executed and the stage result as well as the pipeline result is then set to UNSTABLE. Afterwards stage B is executed. It is successful, but only the unstable post action of stage B is executed instead of its success stage.


      I also found some issues which sound similar to my described problem, like JENKINS-39203. But in my case it's only about the execution and not the visualization. There is also a comment at the end describing something similar....


        Issue Links



              Unassigned Unassigned
              codetent Christoph
              0 Vote for this issue
              2 Start watching this issue