[JIRA] (JENKINS-49947) unclear usage of input step in declarative pipeline

3 views
Skip to first unread message

ak@andreas-klemp-it.de (JIRA)

unread,
Mar 6, 2018, 5:09:02 AM3/6/18
to jenkinsc...@googlegroups.com
Andreas Klemp created an issue
 
Jenkins / Bug JENKINS-49947
unclear usage of input step in declarative pipeline
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2018-03-06 10:08
Environment: Jenkins 2.89.4
Labels: pipeline input when environment
Priority: Minor Minor
Reporter: Andreas Klemp

How is the input step intended to be used in a declarative pipeline using a separate block (JENKINS-48379)? There are several issues with this.

  • The result of the input can only be used in the current stage. Thus, it is not possible to skip multiple stages or use the input value in multiple stages.
  • input and when cannot be combined in all cases. Currently, the result of input can be used in when to skip the stage (cool!). However, if the stage is skipped because of some other criteria, the input is still requested.
  • input cannot be used inside the stage steps as a workaround because the agent would be blocked and it cannot be separated to two steps (approval without agent, handling with agent) because the input result is stage-local.

If I missed something and the issues can be solved, it would be nice to know and the documentation should be more clear about this. Currently, it seems impossible to create a declarative pipeline with a manual approval step before a deployment when the process also depends on other criteria (e.g. the branch in a multibranch pipeline).

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,
Mar 7, 2018, 11:17:02 AM3/7/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Component/s: pipeline-model-definition-plugin
Component/s: pipeline

andrew.bayer@gmail.com (JIRA)

unread,
Mar 7, 2018, 11:17:02 AM3/7/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Mar 7, 2018, 11:23:02 AM3/7/18
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-49947
 
Re: unclear usage of input step in declarative pipeline

The ability to skip multiple stages for a single input result will come along as part of JENKINS-46809 - the architecture makes it not viable to have something that happens in a stage (input, environment, etc) actually carry over as an environment variable to other sibling stages, but sequential nested stages will let you say "here's a parent stage with an input and a when - if the when passes, run this list of other stages".

Ordering is hard. =) I made the call that there was more value in having the result of input available for when than avoiding the input directive if an unrelated when condition was false. It was either input and then when in evaluation order, or when and then input, so...yeah. Again, once JENKINS-46809 lands, you could do a "parent" stage with the branch when condition, with a single nested stage with the input-based when condition. Not the most elegant syntax, sure, but trade-offs have to be made in order to have the opinionated behavior and structure Declarative provides.

ak@andreas-klemp-it.de (JIRA)

unread,
Mar 7, 2018, 3:26:03 PM3/7/18
to jenkinsc...@googlegroups.com

The nested stage is an interesting hint. As far as I see, this is only possible with parallel, so ... yeah ... not optimal. But I'll give it a try with something like this. The downside is, that still only one (sequential) stage can be created.

stage('Release Approval') {
   when {
     branch 'master'
   }
   parallel {
     stage('Release') {
       input {
         # manual approval of release
       }
       when {
         # the release is approved
       }
       steps {
         # release and deployment
       }
     }
  }
}

 

andrew.bayer@gmail.com (JIRA)

unread,
Apr 17, 2018, 5:12:02 PM4/17/18
to jenkinsc...@googlegroups.com

fnasser@redhat.com (JIRA)

unread,
Aug 20, 2018, 6:11:01 PM8/20/18
to jenkinsc...@googlegroups.com

Is it possible to distinguish between 

 
input {

    1. manual approval of release
      }
      when {
    1. the release is approved
      }
      and

    1. when { # the release is approved }
    1. input {

    2. manual approval of release
      }
       

    And make the order of appearance determine what prevails?

     

     

    This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

    fnasser@redhat.com (JIRA)

    unread,
    Aug 22, 2018, 11:49:02 AM8/22/18
    to jenkinsc...@googlegroups.com
    Fernando Nasser edited a comment on Bug JENKINS-49947
    Is it possible to distinguish between 

     
           input \{
             # manual approval of release
           }

           when \{
             # the release is approved
           }

     

    and


           when \ {
             # the release is approved
           }

           input \{
             # manual approval of release
           }      

     

    And make the order of appearance determine what prevails?

    I realize that probably there is no notion of ordering for these declarations, only for stage inside stages (several elements of the same type can be ordered).

     

    Perhaps an input condition to use inside when?

    Or an argument to input to tell it to run after when?

    Of course if this is used the input value cannot be used in the when condition.

     

    I am trying to suggest something here as I have already hit the situation where I wanted them reversed, and I guess we'l have something like 50-50% of us wanting it one way or the other.

     

     

    lum.fitzpatrick@gmail.com (JIRA)

    unread,
    Aug 30, 2018, 10:37:02 AM8/30/18
    to jenkinsc...@googlegroups.com

    I have a similar issue to Fernando Nasser. I have 2 parallel stages, one for dev and one for prod and a when condition determines which stage to run based on the environment. I want to prompt for input in the prod stage only but as the input happens before the when I get prompted for input in regardless of the environment, 

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

    fnasser@redhat.com (JIRA)

    unread,
    Sep 18, 2018, 11:50:02 AM9/18/18
    to jenkinsc...@googlegroups.com

    Perhaps add a 'when' configuration option to the 'input' directive?

    This way we could skip the input for certain cases (like for Liam's prod stage) or even have a different input for each case by playing with the right 'when' conditions.

    andrew.bayer@gmail.com (JIRA)

    unread,
    Nov 15, 2018, 12:04:04 PM11/15/18
    to jenkinsc...@googlegroups.com
    Andrew Bayer resolved as Duplicate
     

    We're adding the ability to have when be evaluated before input runs over at JENKINS-50880.

    Change By: Andrew Bayer
    Status: Open Resolved
    Resolution: Duplicate

    fnasser@redhat.com (JIRA)

    unread,
    May 1, 2019, 5:36:02 PM5/1/19
    to jenkinsc...@googlegroups.com
     
    Re: unclear usage of input step in declarative pipeline

    OK, just for the sake of people who look at this JIRA.

     

    How do we get  when first, input after ?

     

    How do we get  input first, when after ?

     

     

    bitwiseman@gmail.com (JIRA)

    unread,
    Oct 22, 2019, 11:24:53 PM10/22/19
    to jenkinsc...@googlegroups.com
    Liam Newman closed an issue as Duplicate
     

    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