[英]Jenkins secret text credential as variable in pipeline script
我創建了一個秘密文本類型的憑據test_cred
來存儲密碼,該密碼應傳遞給 ansible 劇本。 我將此參數作為額外變量root_pass
傳遞給 ansible,但值root_pass
被評估為字符串test_cred
而不是其中包含的秘密文本。 有人可以幫助獲取憑證test_cred
的值,以便我可以將其傳遞給 ansible。
stages {
stage('Execution') {
steps {
withCredentials([string(credentialsId: 'test_cred', variable: 'test')]) {
}
ansiblePlaybook(
installation: 'ansible',
inventory: "inventory/hosts",
playbook: "${PLAYBOOK}",
extraVars: [
server: "${params.Server}",
client: "${params.Client}",
root_pass: "${test}"
]
)
}
}
}
謝謝 Zeitounator。 工作代碼是:
stages {
stage('Execution') {
steps {
withCredentials([string(credentialsId: 'test_cred', variable: 'test')]) {
ansiblePlaybook(
installation: 'ansible',
inventory: "inventory/hosts",
playbook: "${PLAYBOOK}",
extraVars: [
server: "${params.Server}",
client: "${params.Client}",
root_pass: "${test}"
]
)
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.