[JIRA] (JENKINS-57801) Execution of the wrong post stage block

4 views
Skip to first unread message

dcendents@gmail.com (JIRA)

unread,
May 31, 2019, 2:29:02 PM5/31/19
to jenkinsc...@googlegroups.com
Daniel Beland created an issue
 
Jenkins / Bug JENKINS-57801
Execution of the wrong post stage block
Issue Type: Bug Bug
Assignee: Unassigned
Attachments: image-2019-05-31-14-26-08-781.png
Components: pipeline
Created: 2019-05-31 18:28
Priority: Major Major
Reporter: Daniel Beland

The declarative pipeline documentation on "post" says the following: "These condition blocks allow the execution of steps inside each condition depending on the completion status of the Pipeline or stage"

 

Currently, the post execution of a stage seems to refer to the whole pipeline status at that point and not the completion status of the stage as documented.

 

Given the following pipeline:

pipeline {
  agent any
  stages {
    stage('First') {
      steps { echo 'Hello' }
      post { success { echo 'First stage is success' } }
    }
    stage('Second') {
      steps { sh """ echo '<testsuite errors="1" failures="0" name="test" skipped="0" tests="1" time="1"><testcase classname="" file="file.txt" name="name" time="0.000"><error message="error"></error></testcase></testsuite>' > test-results.xml """ }
      post {
        always { junit 'test-results.xml' }
        unstable { echo 'Second stage is unstable' }
      }
    }
    stage('Third') {
      steps { echo 'Hello' }
      post {
        success { echo 'Third stage is success' }
        unstable { echo 'Third stage is unstable! really???' }
      }
    }
  }
  post { unstable { echo 'Job is unstable' } }
}

I get the following output:

[Pipeline] {
[Pipeline] stage
[Pipeline] { (First)
[Pipeline] echo
Hello
Post stage
[Pipeline] echo
First stage is success
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Second)
[Pipeline] sh
+ echo <testsuite errors="1" failures="0" name="test" skipped="0" tests="1" time="1"><testcase classname="" file="file.txt" name="name" time="0.000"><error message="error"></error></testcase></testsuite>
Post stage
[Pipeline] junit
Recording test results
[Pipeline] echo
Second stage is unstable
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Third)
[Pipeline] echo
Hello
Post stage
[Pipeline] echo
Third stage is unstable! really???
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Job is unstable
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

Clearly the third stage post unstable block is executed even though the stage itself is a success.

This is also contradicted by the blue ocean stage view:

 

 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

james.shorthouse@outlook.com (JIRA)

unread,
Jul 16, 2019, 7:31:02 AM7/16/19
to jenkinsc...@googlegroups.com
James Shorthouse commented on Bug JENKINS-57801
 
Re: Execution of the wrong post stage block

We're having the exact same issue in our pipeline.

Reply all
Reply to author
Forward
0 new messages