Skip to content

Instantly share code, notes, and snippets.

@amitthk
Last active January 21, 2022 21:10
Show Gist options
  • Select an option

  • Save amitthk/517b3db28f5ad5a9892cf6e1dd11f734 to your computer and use it in GitHub Desktop.

Select an option

Save amitthk/517b3db28f5ad5a9892cf6e1dd11f734 to your computer and use it in GitHub Desktop.
jenkinsfile input
stage 'promotion'
def userInput = input(
 id: 'userInput', message: 'Let\'s promote?', parameters: [
 [$class: 'TextParameterDefinition', defaultValue: 'uat', description: 'Environment', name: 'env'],
 [$class: 'TextParameterDefinition', defaultValue: 'uat1', description: 'Target', name: 'target']
])
echo ("Env: "+userInput['env'])
echo ("Target: "+userInput['target'])

and the result will be Running: promotion Entering stage promotion Proceeding Running: Input Input requested Running: Print Message Env: uat Running: Print Message Target: uat1 Running: End of Workflow Finished: SUCCESS If you have only one parameter, its value will be directly returned instead of a Map

stage 'promotion'
def userInput = input(
 id: 'userInput', message: 'Let\'s promote?', parameters: [
 [$class: 'TextParameterDefinition', defaultValue: 'uat', description: 'Environment', name: 'env']
])
echo ("Env: "+userInput)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment