Skip to content

Instantly share code, notes, and snippets.

@rakeyshkande
Forked from amitthk/jenkinsfile.md
Created February 4, 2018 05:28
Show Gist options
  • Select an option

  • Save rakeyshkande/79770fb090e5ffc639dd1ce015f6fcdc to your computer and use it in GitHub Desktop.

Select an option

Save rakeyshkande/79770fb090e5ffc639dd1ce015f6fcdc 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