Ang*_*ina 0 sh jenkins-pipeline
有谁知道如何打印存储在詹金斯中的凭据?下面的脚本抛出:
Unexpected exception caught! groovy.lang.MissingPropertyException: No such property: crd for class: com.test.File
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
服务.groovy
withCredentials([usernamePassword(
credentialsId: vaultCredentialId, usernameVariable: 'ID', passwordVariable: 'CRED')]){
sh """
crd=${CRED}
for chars in `echo $crd | fold -w1`; do echo "value: $chars" ; done
"""
Run Code Online (Sandbox Code Playgroud)
“withCredentials”步骤将屏蔽与其秘密匹配的任何输出,因此如果您想显示它们,则必须在该步骤之外执行此操作。
pipeline {
agent {
label "master"
}
stages {
stage("run") {
steps {
script {
userVar = null
passVar = null
withCredentials([usernamePassword(credentialsId: 'administrator-jenkins', passwordVariable: 'password', usernameVariable: 'username')]) {
userVar = username
passVar = password
}
echo "Username: ${userVar}"
echo "Password: ${passVar}"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3355 次 |
| 最近记录: |