我想gcloud在Jenkins管道中使用,因此必须首先使用Google Service帐户进行身份验证。我使用的是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}"
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过from档案,但是没有运气。
withCredentials([file(credentialsId:'my-creds', variable: 'GCSKEY')]) {
Run Code Online (Sandbox Code Playgroud)
日志显示:
org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: Credentials 'my-creds' is of type 'Google Service Account from private key' ....
Run Code Online (Sandbox Code Playgroud)