Bird
Raised Fist0
Jenkinsdevops~20 mins

Input step for manual approval in Jenkins - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Manual Approval Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Jenkins pipeline snippet with input step?

Consider this Jenkins pipeline snippet:

pipeline {
  agent any
  stages {
    stage('Approval') {
      steps {
        script {
          def userInput = input message: 'Approve deployment?', ok: 'Yes'
          echo "User selected: ${userInput}"
        }
      }
    }
  }
}

What will Jenkins print in the console after the user clicks 'Yes'?

Jenkins
pipeline {
  agent any
  stages {
    stage('Approval') {
      steps {
        script {
          def userInput = input message: 'Approve deployment?', ok: 'Yes'
          echo "User selected: ${userInput}"
        }
      }
    }
  }
}
AUser selected: false
BUser selected: true
CUser selected: Yes
DUser selected: null
Attempts:
2 left
💡 Hint

Think about what the input step returns when the user clicks the OK button with label 'Yes'.

❓ Configuration
intermediate
2:00remaining
Which Jenkinsfile snippet correctly implements a manual approval with a timeout of 5 minutes?

You want to add a manual approval step in your Jenkins pipeline that waits for user input but times out after 5 minutes if no input is given. Which snippet achieves this?

Ainput message: 'Approve?', ok: 'Proceed', timeout: 5, unit: 'MINUTES'
Binput message: 'Approve?', ok: 'Proceed', timeout: 300
Cinput message: 'Approve?', ok: 'Proceed', timeout: 5, timeoutUnit: 'MINUTES'
Dinput message: 'Approve?', ok: 'Proceed', timeout: 5
Attempts:
2 left
💡 Hint

Check the Jenkins input step documentation for the correct way to specify timeout in seconds.

❓ Troubleshoot
advanced
2:00remaining
Why does this Jenkins pipeline fail with an error during the input step?

Given this snippet:

stage('Approval') {
  steps {
    input 'Approve deployment?'
    echo 'Deployment approved'
  }
}

When running, Jenkins throws an error: java.lang.IllegalArgumentException: No valid parameters provided. What is the cause?

Jenkins
stage('Approval') {
  steps {
    input 'Approve deployment?'
    echo 'Deployment approved'
  }
}
AThe input step requires a message parameter with key 'message', not a plain string.
BThe input step requires at least one button label specified with 'ok' parameter.
CThe input step cannot be used inside steps block, it must be in script block.
DThe input step requires a timeout parameter to avoid errors.
Attempts:
2 left
💡 Hint

Check the required parameters for the input step in Jenkins pipeline.

🔀 Workflow
advanced
2:00remaining
What happens to the Jenkins pipeline if the input step times out?

Consider this pipeline snippet:

stage('Approval') {
  steps {
    input message: 'Approve?', ok: 'Yes', timeout: 60
    echo 'Approved'
  }
}

If no user input is given within 60 seconds, what is the pipeline behavior?

Jenkins
stage('Approval') {
  steps {
    input message: 'Approve?', ok: 'Yes', timeout: 60
    echo 'Approved'
  }
}
AThe pipeline aborts the build with an error.
BThe pipeline continues immediately to the next step without approval.
CThe pipeline retries the input step indefinitely.
DThe pipeline pauses indefinitely until manual intervention.
Attempts:
2 left
💡 Hint

Think about what Jenkins does when a timeout occurs on an input step.

✅ Best Practice
expert
3:00remaining
Which Jenkins pipeline snippet correctly captures user input with multiple options and stores the result?

You want to ask the user to select an environment to deploy to, with options 'dev', 'staging', and 'prod'. The pipeline should store the selected environment in a variable. Which snippet does this correctly?

Adef env = input message: 'Select environment', parameters: [password(name: 'env', defaultValue: 'dev', description: 'Choose environment')]
Bdef env = input message: 'Select environment', parameters: [string(name: 'env', defaultValue: 'dev', description: 'Choose environment')]
Cdef env = input message: 'Select environment', ok: 'Select', parameters: [booleanParam(name: 'env', defaultValue: true, description: 'Choose environment')]
Ddef env = input message: 'Select environment', parameters: [choice(name: 'env', choices: 'dev\nstaging\nprod', description: 'Choose environment')]
Attempts:
2 left
💡 Hint

Which parameter type allows selecting from multiple predefined options?

Practice

(1/5)
1. What is the main purpose of the input step in a Jenkins pipeline?
easy
A. To send email notifications
B. To automatically deploy the application
C. To run tests in parallel
D. To pause the pipeline and wait for manual approval

Solution

  1. Step 1: Understand the role of the input step

    The input step is designed to pause the pipeline execution and wait for a user to approve or reject the continuation.
  2. Step 2: Compare with other pipeline actions

    Other options like deployment, testing, or notifications are handled by different steps, not input.
  3. Final Answer:

    To pause the pipeline and wait for manual approval -> Option D
  4. Quick Check:

    Input step = manual pause [OK]
Hint: Input step always waits for user action [OK]
Common Mistakes:
  • Confusing input with automated steps
  • Thinking input triggers deployment
  • Assuming input sends notifications
2. Which of the following is the correct syntax to add a manual approval input step in a Jenkins declarative pipeline?
easy
A. input message: 'Approve deployment?'
B. input('Approve deployment?')
C. input { message: 'Approve deployment?' }
D. input message = 'Approve deployment?'

Solution

  1. Step 1: Recall Jenkins input step syntax

    The correct syntax uses the input step with named parameters like message: 'text'.
  2. Step 2: Check each option

    input message: 'Approve deployment?' matches the correct syntax. Options A, B, and D use incorrect formats or braces.
  3. Final Answer:

    input message: 'Approve deployment?' -> Option A
  4. Quick Check:

    Correct input syntax uses named parameters [OK]
Hint: Use named parameters with colon for input step [OK]
Common Mistakes:
  • Using parentheses instead of named parameters
  • Using braces instead of parentheses
  • Assigning message with equals sign
3. Given the following Jenkins scripted pipeline snippet, what will happen when it reaches the input step?
node {
  stage('Build') {
    echo 'Building...'
  }
  stage('Approval') {
    input message: 'Proceed with deployment?'
  }
  stage('Deploy') {
    echo 'Deploying...'
  }
}
medium
A. Pipeline pauses and waits for user approval before deploying
B. Pipeline skips the approval and deploys immediately
C. Pipeline fails with a syntax error
D. Pipeline runs all stages without pause

Solution

  1. Step 1: Analyze the input step behavior

    The input step pauses the pipeline and waits for a user to approve before continuing.
  2. Step 2: Understand pipeline flow

    After approval, the pipeline proceeds to the Deploy stage. Without approval, it stays paused.
  3. Final Answer:

    Pipeline pauses and waits for user approval before deploying -> Option A
  4. Quick Check:

    Input step pauses pipeline = Pipeline pauses and waits for user approval before deploying [OK]
Hint: Input step always pauses pipeline until user approves [OK]
Common Mistakes:
  • Assuming input step is skipped automatically
  • Thinking input causes syntax error
  • Believing pipeline runs all stages without pause
4. Identify the error in this Jenkins pipeline snippet that uses an input step:
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        input message: 'Approve test run?'
        echo 'Running tests...'
      }
    }
  }
}
medium
A. The message parameter is missing quotes
B. The input step cannot be used in the Test stage
C. The input step must be inside a script block in declarative pipeline
D. The echo step must come before the input step

Solution

  1. Step 1: Understand declarative pipeline input usage

    In declarative pipelines, the input step must be wrapped inside a script block to run scripted steps.
  2. Step 2: Check the snippet

    The input step is directly inside steps without script, causing a syntax error.
  3. Final Answer:

    The input step must be inside a script block in declarative pipeline -> Option C
  4. Quick Check:

    Input in declarative needs script block [OK]
Hint: Wrap input step in script block in declarative pipelines [OK]
Common Mistakes:
  • Placing input step directly in steps without script
  • Missing quotes around message
  • Thinking input can't be used in certain stages
5. You want to add a manual approval step in a Jenkins declarative pipeline that asks the user to confirm deployment with a custom message and a timeout of 1 hour. Which snippet correctly implements this?
hard
A. input message: 'Deploy now?', timeout: 3600
B. script { input message: 'Deploy now?', timeout: 3600 }
C. script { input message: 'Deploy now?', timeout: 60, submitter: 'admin' }
D. script { input message: 'Deploy now?', timeout: 60 }

Solution

  1. Step 1: Understand timeout parameter unit

    The timeout parameter for input is in seconds, so 1 hour = 3600 seconds.
  2. Step 2: Check declarative pipeline syntax

    Input must be inside a script block in declarative pipelines.
  3. Step 3: Evaluate options

    script { input message: 'Deploy now?', timeout: 3600 } correctly uses script block and timeout 3600 seconds. script { input message: 'Deploy now?', timeout: 60 } uses 60 (1 minute), B lacks script block, C adds submitter but timeout is 60 seconds.
  4. Final Answer:

    script { input message: 'Deploy now?', timeout: 3600 } -> Option B
  5. Quick Check:

    Timeout in seconds + script block = script { input message: 'Deploy now?', timeout: 3600 } [OK]
Hint: Timeout is seconds; use script block in declarative [OK]
Common Mistakes:
  • Using timeout in minutes instead of seconds
  • Omitting script block in declarative pipeline
  • Adding unnecessary parameters
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard