[JIRA] (JENKINS-61101) Mutually exclusive stages in declarative pipeline

0 views
Skip to first unread message

rittneje@gmail.com (JIRA)

unread,
Feb 14, 2020, 4:24:03 PM2/14/20
to jenkinsc...@googlegroups.com
Jesse Rittner created an issue
 
Jenkins / New Feature JENKINS-61101
Mutually exclusive stages in declarative pipeline
Issue Type: New Feature New Feature
Assignee: Andrew Bayer
Components: blueocean-plugin, pipeline-model-definition-plugin
Created: 2020-02-14 21:23
Priority: Minor Minor
Reporter: Jesse Rittner

There have been a few cases where I've needed to define a set of mutually exclusive stages of which only one should execute. Right now this can be accomplished with a parallel block containing stages with inter-related when conditions, but this is annoying to manage. I propose adding a new switch block to stage.

 

stage ("Do It") {
    switch {
        stage("Stage A") {
            when { expression { return conditionA } }
            steps { ... }
        }
        stage("Stage B") {
             when { expression { return conditionB } }
             steps { ... }
        }
        stage("Stage C") {
            steps { ... }
        }
    }
}

This means "If condition A, do Stage A. Else if condition B, do Stage B. Else, do Stage C." switch would be at the same level as stagesparallel, and matrix today. This allows Blue Ocean to clearly display the mutually exclusive stages (probably in a vertical arrangement, like it does for parallel).

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

jenkins@gavinmogan.com (JIRA)

unread,
Feb 15, 2020, 1:40:02 PM2/15/20
to jenkinsc...@googlegroups.com
Gavin Mogan updated an issue
Change By: Gavin Mogan
Component/s: blueocean-plugin

bitwiseman@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:24:02 PM3/4/20
to jenkinsc...@googlegroups.com
Liam Newman assigned an issue to Liam Newman
Change By: Liam Newman
Assignee: Andrew Bayer Liam Newman
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

bitwiseman@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:29:05 PM3/4/20
to jenkinsc...@googlegroups.com
Liam Newman commented on New Feature JENKINS-61101
 
Re: Mutually exclusive stages in declarative pipeline

I love this syntax. Very elegant.

I'm not sure exactly how it should be implemented yet.

I agree it would be nice to have blue ocean display these vertically, but that would mean implementing/exposing the switch as though it were a parallel with would limit where it could be used - for instance then we couldn't have a switch inside a switch.

Reply all
Reply to author
Forward
0 new messages