red*_*888 3 jenkins jenkins-plugins jenkins-pipeline
我有相同的凭据,需要以两种不同的方式为不同的命令注入。作为原始文本和 json 文件的文件路径。
我试图这样做,但它不起作用:
GOOGLE_APPLICATION_CREDENTIALS = credentials('myjsonkey')
GOOGLE_CREDENTIALS = "${new File( credentials('myjsonkey') ).text}"
Run Code Online (Sandbox Code Playgroud)
在管道中,必须像这样访问秘密文件
withCredentials([file(credentialsId: 'pets-id', variable: 'mySecretFile')]) {
// some block can be a groovy block as well and the variable will be available to the groovy script
sh '''
echo "This is the directory of the secret file $mySecretFile"
echo "This is the content of the file `cat $mySecretFile`"
'''
}
Run Code Online (Sandbox Code Playgroud)
“pets-id”是我为凭证提供的 ID。
| 归档时间: |
|
| 查看次数: |
12891 次 |
| 最近记录: |