我有以下DSL結構:如何在Jenkins作業DSL中加載AWS憑證?
freeStyleJob {
wrappers {
credentialsBinding {
[
$class:"AmazonWebServicesCredentialsBinding",
accessKeyVariable: "AWS_ACCESS_KEY_ID",
credentialsId: "your-credential-id",
secretKeyVariable: "AWS_SECRET_ACCESS_KEY"
]
}
}
steps {
// ACCESS AWS ENVIRONMENT VARIABLES HERE!
}
}
但是,這是行不通的。這樣做的正確語法是什麼?對於Jenkins管線,你可以這樣做:
withCredentials([[
$class: "AmazonWebServicesCredentialsBinding",
accessKeyVariable: "AWS_ACCESS_KEY_ID",
credentialsId: "your-credential-id",
secretKeyVariable: "AWS_SECRET_ACCESS_KEY"]]) {
// ACCESS AWS ENVIRONMENT VARIABLES HERE!
}
但是這個語法在正常的DSL作業中不起作用。
tl; dr如何將AmazonWebServicesCredentialsBinding插件定義的AWS憑證導出到Groovy作業DSL的環境變量中? (不!流水線插件語法)
這並沒有爲我工作的另一種方法。 –
你有amazonWebServicesCredentialsBinding [插件安裝在你的Jenkins](https://wiki.jenkins.io/display/JENKINS/CloudBees+AWS+Credentials+Plugin)嗎?另外,你得到的錯誤是什麼? –