[JIRA] (JENKINS-50880) Create a new option for running when condition before stage input

3 views
Skip to first unread message

erik.elkins@outlook.com (JIRA)

unread,
Apr 18, 2018, 5:16:03 PM4/18/18
to jenkinsc...@googlegroups.com
Erik Elkins updated an issue
 
Jenkins / New Feature JENKINS-50880
Create a new option for running when condition before stage input
Change By: Erik Elkins
Summary: Create a new stage option for running when condition before stage input
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

torsten.kleiber@ikb.de (JIRA)

unread,
Jun 15, 2018, 8:08:02 AM6/15/18
to jenkinsc...@googlegroups.com
Torsten Kleiber commented on New Feature JENKINS-50880
 
Re: Create a new option for running when condition before stage input

We have the same requirement, business case is following:

  • in multibranch pipeline we want to run the build for every branch but
  • deployment should be done only for the master- or hotfix-branches
  • after manual confirmation
  • in other branches the deployment should be skipped without interaction

christopher.fenner@sap.com (JIRA)

unread,
Jun 28, 2018, 8:22:02 AM6/28/18
to jenkinsc...@googlegroups.com

We have the same requirement:

  • run a stage with input only for specific branches
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

andrew.bayer@gmail.com (JIRA)

unread,
Aug 9, 2018, 2:02:02 PM8/9/18
to jenkinsc...@googlegroups.com

vincent.letarouilly@gmail.com (JIRA)

unread,
Oct 3, 2018, 5:34:08 AM10/3/18
to jenkinsc...@googlegroups.com
Vincent Letarouilly edited a comment on New Feature JENKINS-50880
 
Re: Create a new option for running when condition before stage input
I found a workaround, just put your input directive inside the steps one like that

 
{code:java}
stage('Production Deploy') {
    agent

{ label 'linux' }
    when
{
{         branch "master"    }
    steps
{
{         input \{ message 'Deploy to Production?' }
        echo 'Deploying to Production ... '    }             
}

{code}
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

vincent.letarouilly@gmail.com (JIRA)

unread,
Oct 3, 2018, 5:34:09 AM10/3/18
to jenkinsc...@googlegroups.com

I found a workaround, just put your input directive inside the steps one like that

stage('Production Deploy') {
    agent

{ label 'linux' }

    when

{      branch "master"    }

    steps

{ input \{ message 'Deploy to Production?' }

echo 'Deploying to Production ... '  }             
}

vincent.letarouilly@gmail.com (JIRA)

unread,
Oct 3, 2018, 5:35:06 AM10/3/18
to jenkinsc...@googlegroups.com
Vincent Letarouilly edited a comment on New Feature JENKINS-50880
I found a workaround, just put your input directive inside the steps one like that

 
{code:java}

stage('Production Deploy') {
    agent
{ label 'linux' }
  
  when
{
      branch "master"     
}
    steps

{
input \ { message 'Deploy to Production?' }
echo 'Deploying to Production ... '
 
}             
}
{code}
 

torsten.kleiber@ikb.de (JIRA)

unread,
Oct 5, 2018, 2:23:01 AM10/5/18
to jenkinsc...@googlegroups.com

This workaround blocks an executor for the time waiting for input. Following is wanted (as described in https://jenkins.io/blog/2018/04/09/whats-in-declarative/)

 

pipeline {
    agent none // no executor is blocked 
    stages {
        stage('Production Deploy') {
            when {
                branch 'master'
                // beforeInput: true
            }
            input { 
                message 'Deploy to Production?' // For this input can be waited several days
            }
            agent any // From here on for executing the steps an executor is needed
            steps {
                echo 'Deploying to Production ... '
            }
        }
    }
}

jtaboada@cloudbees.com (JIRA)

unread,
Nov 8, 2018, 10:01:02 AM11/8/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Nov 9, 2018, 9:55:03 AM11/9/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Currently, when using the "stage-level" input (here: [https://jenkins.io/doc/book/pipeline/syntax/#input)] the when condition of the stage is evaluated after the input is gathered.  We should add an option so the when condition is evaluated before the input is gathered. Something like:

{code:java}
stage('Production Deploy') {
    agent { label 'linux' }
    when {
        branch "master"
        beforeInput : true

    }
   input { message 'Deploy to Production?' }
    steps {
        echo 'Deploying to Production ... '
    }             
}{code}
 
*Use cases*
* Evaluate the when condition before the input has been gathered.

*In scope*
* Declarative pipeline only
* Only used for input at stage level https://jenkins.io/doc/book/pipeline/syntax/#input

 

jtaboada@cloudbees.com (JIRA)

unread,
Nov 13, 2018, 11:29:03 AM11/13/18
to jenkinsc...@googlegroups.com
Status: Open In Progress

jtaboada@cloudbees.com (JIRA)

unread,
Nov 23, 2018, 6:29:03 AM11/23/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Nov 27, 2018, 7:26:04 AM11/27/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated New Feature JENKINS-50880
 

This’ll be in 1.3.3

Change By: Andrew Bayer
Status: In Review Resolved
Resolution: Fixed

johan.rydstrom@gmail.com (JIRA)

unread,
Nov 27, 2018, 6:21:03 PM11/27/18
to jenkinsc...@googlegroups.com
Johan Rydström commented on New Feature JENKINS-50880
 
Re: Create a new option for running when condition before stage input

Looks good!

Q: Can I, and if so how can I make the result of the captured input (the approver) available in a variable?

torsten.kleiber@ikb.de (JIRA)

unread,
Nov 28, 2018, 1:46:02 AM11/28/18
to jenkinsc...@googlegroups.com

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:32 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

adrien.lecharpentier@gmail.com (JIRA)

unread,
Oct 27, 2019, 4:06:03 PM10/27/19
to jenkinsc...@googlegroups.com
Adrien Lecharpentier commented on New Feature JENKINS-50880
 
Re: Create a new option for running when condition before stage input

Just a warning, the beforeInput is not documented in the article nor in the snippet generator. I just faced this and the only solution is in Torsten's comment.

Reply all
Reply to author
Forward
0 new messages