我正在尝试使用 Jenkins Credentials 插件来获取用户输入并在 Jenkinsfile 中使用它进行处理。由于密码字段高度敏感,我希望凭据插件能够屏蔽密码,使其不显示在控制台输出中。但是似乎密码以纯文本形式显示。我注意到一个现有问题https://issues.jenkins-ci.org/browse/JENKINS-38181 https://issues.jenkins-ci.org/browse/JENKINS-38181其中讨论了 withCredentials 块之外的 echo 语句,以纯文本形式显示密码,这是预期的。但就我而言,即使 withCredentials 块内的 echo 语句也会显示为普通。
我在这里做错了什么吗?我应该避免使用 echo 吗?
凭证绑定插件:1.12
凭证插件:2.1.16
node('someagent') {
stage 'input'
def userNameInput = input(
id: 'UserName', message: 'input your username: ', ok: 'ok', parameters: [string(defaultValue: 'user', description: '.....', name: 'DB_USER')]
)
def userPasswordInput = input(
id: 'Password', message: 'input your password: ', ok: 'ok', parameters: [string(defaultValue: 'password', description: '.....', name: 'DB_PASS')]
)
withCredentials(bindings: [usernamePassword(credentialsId: 'CREDS', usernameVariable: userNameInput, variable: userPasswordInput)]) {
echo ("My Username: ${userNameInput}")
echo ("My Password: ${userPasswordInput}")
}
}
控制台输出:
[Pipeline] {
[Pipeline] stage (input)
Using the ‘stage’ step without a block argument is deprecated
Entering stage input
Proceeding
[Pipeline] input
Input requested
Approved by UserId
[Pipeline] input
Input requested
Approved by UserId
[Pipeline] withCredentials
[Pipeline] {
[Pipeline] echo
My Username: user
[Pipeline] echo
My Password: password
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS