我想用gcloud
在 Jenkins 管道中,因此我必须首先使用 Google 服务帐户进行身份验证。我正在使用https://wiki.jenkins.io/display/JENKINS/Google+OAuth+Plugin https://wiki.jenkins.io/display/JENKINS/Google+OAuth+Plugin其中保存着我的私钥凭证。我一直坚持将凭据加载到管道中:
withCredentials([[$class: 'MultiBinding', credentialsId: 'my-creds', variable: 'GCSKEY']]) {
sh "gcloud auth activate-service-account --key-file=${GCSKEY}"
}
我也尝试过使用 from file,但没有运气。
withCredentials([file(credentialsId:'my-creds', variable: 'GCSKEY')]) {
日志说:
org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: Credentials 'my-creds' is of type 'Google Service Account from private key' ....
您需要将服务帐户 JSON 文件上传为秘密文件.
Then:
withCredentials([file(credentialsId: 'key-sa', variable: 'GC_KEY')]) {
sh("gcloud auth activate-service-account --key-file=${GC_KEY}")
sh("gcloud container clusters get-credentials prod --zone northamerica-northeast1-a --project ${project}")
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)