Shu*_*ngh 3 jenkins google-cloud-platform
当我使用下面的代码时,我没有获得谷歌凭据。def GOOGLE_CREDENTIALS = 凭证('XYZ 凭证')
[编辑]
请检查这个官方指南,看看你的定义是否正确。
另请检查您是否传递凭据 ID,而不是credentials()方法的描述。
如果您使用 Jenkins 管道,您还可以尝试Credentials Binding Plugin。从插件wiki来看,用户名密码类型凭证的典型示例如下所示:
withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
// available as an env variable, but will be masked if you try to print it out any which way
// note: single quotes prevent Groovy interpolation; expansion is by Bourne Shell, which is what you want
sh 'echo $PASSWORD'
// also available as a Groovy variable
echo USERNAME
// or inside double quotes for string interpolation
echo "username is $USERNAME"
}
Run Code Online (Sandbox Code Playgroud)
withCredentials()对于脚本化管道,您也可以使用(请参阅此):
node {
withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable: 'USERPASS')]) {
sh '''
set +x
curl -u "$USERPASS" https://private.server/ > output
'''
}
}
Run Code Online (Sandbox Code Playgroud)
或者您可以使用withEnv()部分:
node {
withEnv(["CREDS=credentials('jenkins-creds')"]) {
stage('Build') {
sh 'printenv'
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9849 次 |
| 最近记录: |