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

Input/parameters for Stages

XMLWordPrintable

    • Pipeline - December

      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')
          ...
        }
      }
      

            abayer Andrew Bayer
            jamesdumay James Dumay
            Votes:
            2 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: