Jenkins pipeline parameters select
时间: 2023-07-11 22:06:27 浏览: 123
Jenkins pipeline parameters can be defined using the `parameters` block in the pipeline script. To create a parameter of type select, you can use the following syntax:
```
parameters {
select(
name: 'PARAM_NAME',
choices: ['CHOICE_1', 'CHOICE_2', 'CHOICE_3'],
description: 'Select an option'
)
}
```
In this example, replace `PARAM_NAME` with the name of your parameter, `CHOICE_1`, `CHOICE_2`, and `CHOICE_3` with the options you want to offer, and `Select an option` with a description of the parameter to be displayed to the user.
You can use the selected value in your pipeline script using the `params.PARAM_NAME` syntax. For example:
```
stage('Example') {
steps {
echo "Selected option: ${params.PARAM_NAME}"
}
}
```
This will display the selected option in the build logs.
阅读全文