han*_*ase 5 jenkins jenkins-pipeline
我有一个 Jenkinsfile 实例,使用 ansible-playbook 来部署 webmachine。
我需要一次指定多个 ansible-playbook 参数。
我有
WorkflowScript:25:多次出现参数部分
我的 jenkinsfile 像这样,
pipeline {
agent none
stages {
stage('docker-compose up') {
input {
message "Should we continue?"
ok "Yes, do it!"
parameters {
string(name: 'KIBANA_TAG', defaultValue: '', description: 'input tag for ansible command.')
}
parameters {
string(name: 'FLUENT_TAG', defaultValue: '', description: 'input tag for ansible command.')
}
parameters {
string(name: 'ES_TAG', defaultValue: '', description: 'input tag for ansible command.')
}
parameters {
string(name: 'HOST', defaultValue: '', description: 'input tag for ansible command.')
}
}
steps {
sh "rd6-admin@qa ansible-playbook /tmp/qa/docker-compose-up.yml -e fluent_tag=${params.FLUENT_TAG} -e kibana_tag=${params.KIBANA_TAG} -e es_tag=${params.ES_TAG} -e host=${params.HOST}"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我应该修复哪个部分?
parameters {
string(name: 'KIBANA_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
string(name: 'FLUENT_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
string(name: 'ES_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
string(name: 'HOST', defaultValue: 'default', description: 'input tag for ansible command.')
}
Run Code Online (Sandbox Code Playgroud)
尝试这个。参数部分多次出现意味着只允许使用一个参数,并且您必须将参数放在其中。{}
小智 6
逗号分隔符在版本 2.222.1 中不起作用。我删除了逗号,现在可以使用了。
parameters {
string(name: 'KIBANA_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
string(name: 'FLUENT_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
string(name: 'ES_TAG', defaultValue: 'default', description: 'input tag for ansible command.')
string(name: 'HOST', defaultValue: 'default', description: 'input tag for ansible command.')
}
Run Code Online (Sandbox Code Playgroud)