我的例子:
pipeline {
agent any
parameters {
choice(
name: 'myParameter',
choices: "Option1\Option2",
description: 'interesting stuff' )
}
}
Run Code Online (Sandbox Code Playgroud)
输出错误:
" unexpected char: '\' " on the line with "choices" "
Run Code Online (Sandbox Code Playgroud)
请遵循以下说明:https : //github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Parametrized-pipelines
对我做错的任何想法或建议吗?
小智 20
声明性詹金斯管道的文档说:
一个选择参数,例如:
pipeline {
.....
parameters {
choice(name: 'CHOICES', choices: ['one', 'two', 'three'], description: '') }
Run Code Online (Sandbox Code Playgroud)
第一个是默认值
小智 9
您需要使用\n而不是\。参见以下代码:
pipeline {
agent any
parameters {
choice(
name: 'myParameter',
choices: "Option1\nOption2",
description: 'interesting stuff' )
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
可以说是最优雅的分离选项的方法是使用像这样的数组:
pipeline {
agent any
parameters {
choice(
name: 'Env',
choices: ['DEV', 'QA', 'UAT', 'PROD'],
description: 'Passing the Environment'
)
}
stages {
stage('Environment') {
steps {
echo " The environment is ${params.Env}"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14687 次 |
| 最近记录: |