【发布时间】:2022-01-06 15:57:12
【问题描述】:
我是詹金斯的新手。尝试创建一个使用基于选择的参数的基本管道。以下是我的脚本。
代码----
pipeline{
agent {
label 'agent'
}
parameters {
choice choices: ['John', 'Stacy'], description: 'Choose one', name: 'Person'
}
stages {
stage('Print') {
steps {
echo "Hello ${params.Person}"
sh """if (${params.Person} = "John")
then
echo "Person is male."
else
echo "Person is female."
fi"""
}
}
}
}
现在无论我选择什么选项,我的构建都会成功完成。它总是显示结果“人是女性。
以下是我的一个构建的结果。
Started by user ****
[Pipeline] Start of Pipeline
[Pipeline] node
Running on agent in
/home/temp/jenkins_agent/workspace/ChoiceBased PL
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Print)
[Pipeline] echo
Hello John
[Pipeline] sh
+ John = John
/home/temp/jenkins_agent/workspace/ChoiceBased PL@tmp/durable-
b7e98c46/script.sh: 1: John: not found
+ echo Person is female.
Person is female.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
完成:成功
请建议我缺少什么?
【问题讨论】:
标签: jenkins jenkins-pipeline parameter-passing