Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48379

Input/parameters for Stages

    XMLWordPrintable

    Details

    • Sprint:
      Pipeline - December
    • Similar Issues:

      Description

      Problem
      If an input is used within a stage that uses an agent, it will block the agent from being used until the input proceeds.

      stage('rollback') {
        agent {
          label 'deployer-agent'
        }
        steps {
          input 'should I rollback?' // blocks agent 'deployer-agent'
        }
      }
      

      Solution
      Introduce a input directive inside stage that blocks the stage from executing and acquiring the agent.

      stage('rollback') {
        input {
          message 'should I rollback?'
        }
        agent {
          label 'deployer-agent'
        }
        steps {
          echo 'deploying'
        }
      }
      

      This would be the same in scripted pipeline:

      stage('rollback') {
        input 'should I rollback?'
        node ('deployer-agent') {
          echo 'deploying'
        }
      }
      

      Full Syntax

      input {
        // Parameters are all the same as the input step. Only message is required.
        message "Should we continue?"
        id "some-id" // optional, defaults to stage name.
        ok "For the OK button"
        submitter "alice,bob"
        submitterParameter "approver"
        parameters {
          // Same syntax as top-level parameters block
          booleanParam(name: 'someParam', defaultValue: true, description: 'some description')
          ...
        }
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            tkleiber Torsten Kleiber added a comment -

            Thanks I have bookmarked this, but not read before. Stage timeouts seems what I need!

            Show
            tkleiber Torsten Kleiber added a comment - Thanks I have bookmarked this, but not read before. Stage timeouts seems what I need!
            Hide
            rmpestano Rafael Pestano added a comment -

            Just tested and is working great:

            pipeline {
            
             agent none
            
             stages {
            
                stage("deploy to production ") {
                        options {
                            timeout(time: 1, unit: 'DAYS')
                        }
                        input {
                            message "Approve deploy?"
                            ok "Yes"
                        }
                        agent  any //must be declared after input directive
                        steps {
                          deploy env: 'PRODUCTION' 
                        }
                    }
            
               }//end stages
            
               post {
                    always {
                         node('master') { //important because the pipeline agent is none and some plugins may need to access the workspace
                             lastChanges()
                         }
                    }
                }  
            
            } //end pipeline
            
            Show
            rmpestano Rafael Pestano added a comment - Just tested and is working great: pipeline { agent none stages { stage( "deploy to production " ) { options { timeout(time: 1, unit: 'DAYS' ) } input { message "Approve deploy?" ok "Yes" } agent any //must be declared after input directive steps { deploy env: 'PRODUCTION' } } } //end stages post { always { node( 'master' ) { //important because the pipeline agent is none and some plugins may need to access the workspace lastChanges() } } } } //end pipeline
            Hide
            michaelneale Michael Neale added a comment -

            nice - Torsten Kleiber should add this to docs!

            Show
            michaelneale Michael Neale added a comment - nice - Torsten Kleiber should add this to docs!
            Hide
            tkleiber Torsten Kleiber added a comment -

            Don't understand - what do you mean by this?

            Show
            tkleiber Torsten Kleiber added a comment - Don't understand - what do you mean by this?
            Hide
            michaelneale Michael Neale added a comment -

            Torsten Kleiber oh just mean that the docs website would ideally cover this feature (if it doesn't already) - nothing more than that. 

            Show
            michaelneale Michael Neale added a comment - Torsten Kleiber oh just mean that the docs website would ideally cover this feature (if it doesn't already) - nothing more than that. 

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                jamesdumay James Dumay
              • Votes:
                2 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: