[JIRA] (JENKINS-52114) Declarative Pipeline Parallel Stages Post Events non-deterministic

2 views
Skip to first unread message

bklos89@gmail.com (JIRA)

unread,
Jun 21, 2018, 11:12:02 AM6/21/18
to jenkinsc...@googlegroups.com
Brandon Klos created an issue
 
Jenkins / Bug JENKINS-52114
Declarative Pipeline Parallel Stages Post Events non-deterministic
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: core, pipeline-model-definition-plugin
Created: 2018-06-21 15:11
Environment: Jenkins v2.121.1, Pipeline: Declarative Plugin v1.3
Labels: pipeline
Priority: Minor Minor
Reporter: Brandon Klos

The Jenkins Declarative Pipeline is experiencing non-deterministic results when entering the post steps for parallel stages. For example, when an error is raised in one of two parallel stages and the other stage succeeds, but finish around the same time, then the successful stage executes the failure post stage, instead of the successful.

stage("Parallel stages") {
    parallel {
        stage("Stage 1"){
            agent none
            steps {
                script {
                    // sleep 10 // when sleeping long enough, stages behave correctly.
                    error("Which post step will get executed?")
                }
            }
            post {
                success {
                    echo "Stage 1 success!"
                }
                failure {
                    echo "Stage 1 failure!"
                }
            }
        }
        stage("Stage 2"){
            agent none
            steps {
                script {
                    echo "Stage 2 code executing..."
                }
            }
            post {
                success {
                    echo "Stage 2 success!"
                }
                failure {
                    echo "Stage 2 failure!"
                }
            }
        }
    }
    post {
        success {
            echo "Parallel post steps success!"
        }
        failure {
            echo "Parallel post steps failure!"
        }
    }
}

 

So when Stage 1 has the sleep step commented out the results I see are:

[Stage 1] Stage 1 failure!

[Stage 2] Stage 2 failure!

Parallel post steps failure!

 

But when Stage 1 has the sleep step active, the results I see are:

[Stage 1] Stage 1 failure!

[Stage 2] Stage 2 success!

Parallel post steps failure!

 

I should expect the second scenario in all situations, right?

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Jun 21, 2018, 11:23:01 AM6/21/18
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-52114
 
Re: Declarative Pipeline Parallel Stages Post Events non-deterministic

Regrettably, it actually is deterministic, it's just kinda crappy. =) The failure/success doesn't actually refer to failure/success of the individual stage, but of the build as a whole at the time that the post block is evaluated. So if stage 1 hasn't finished yet when stage 2 finishes, the build status is still success.

This is, yes, annoying. There's an open ticket for better per-stage status tracking, and independent of that, I might be able to tweak the success condition specifically to be more stage-specific (though failure/unstable/aborted would still have to look at the overall build status). Will update once I have a chance to experiment.

bklos89@gmail.com (JIRA)

unread,
Jun 21, 2018, 12:25:02 PM6/21/18
to jenkinsc...@googlegroups.com

I would expect that the post sections for each stage react independently of other concurrent stages. There is a post section for the parallel stages as a whole. The outer post section is where I would expect to see an error 100% of the time when a build failure occurs in either parallel stage.

From my understanding the post stages are intended to perform some work that may be specific for the result of that stage. If I randomly have a stage execute the wrong post step, then I get unintentional (appearing non-deterministic) results.

In either case, yes, this is annoying. In one other scenario, we sent a notification out saying two stages were marked as unstable. In the meantime, only one stage was unstable. Figuring out which it was, was kind of annoying.

andrew.bayer@gmail.com (JIRA)

unread,
Aug 7, 2018, 9:26:03 AM8/7/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
 
Change By: Andrew Bayer
Component/s: core
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

andrew.bayer@gmail.com (JIRA)

unread,
Aug 23, 2018, 12:33:02 PM8/23/18
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-52114
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Aug 23, 2018, 12:34:03 PM8/23/18
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-52114
 
Re: Declarative Pipeline Parallel Stages Post Events non-deterministic

I may have a solution for this specifically for success and failure - unstable will still need JENKINS-39203, though, and there's no way I can have it fire failure if you do currentBuild.result = "FAILURE" in a stage and not fire failure for a successful parallel stage with a failing sibling, but hey.

andrew.bayer@gmail.com (JIRA)

unread,
Aug 23, 2018, 12:57:06 PM8/23/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Aug 23, 2018, 12:57:06 PM8/23/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Aug 31, 2018, 4:02:02 PM8/31/18
to jenkinsc...@googlegroups.com
 

Ok, this change will be in 1.3.2, which is releasing momentarily!

Change By: Andrew Bayer
Status: In Review Resolved
Resolution: Fixed
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:26 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages