Currently I have a pipeline job which has different paramters where one of this parameters is a Choice parameter. Here is the config.xml output of that job parameter:
<
As documented at https://www.jenkins.io/doc/book/pipeline/syntax/#parameters in September 2020, the documented syntax to use a choice parameter in a pipeline is:
pipeline {
agent any
parameters {
choice(
name: 'CHOICE',
choices: ['one', 'two', 'three'],
description: ''
)
}
stages {
stage('Example') {
steps {
echo "Choice: ${params.CHOICE}"
sh "echo Choice: ${params.CHOICE}"
sh 'echo Choice: $CHOICE'
}
}
}
}
In testing, the choice defaults to the first parameter in the list, I have not looked into if this has potential to be otherwise.
All three versions of the task perform the same. Note the specific quotes used.