在不使用WithCredentials的情况下将密码隐藏在Jenkins Pipeline日志输出中 [英] Hiding passwords in Jenkins Pipeline log output without using WithCredentials

查看:444
本文介绍了在不使用WithCredentials的情况下将密码隐藏在Jenkins Pipeline日志输出中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Jenkinsfile的参数化Jenkins管道.一些参数包含敏感密码,我不想出现在作业的构建日志中.

所以我的问题是:我可以在Jenkinsfile内以某种方式注册一个字符串,然后在出现在日志输出中时将其替换为**********吗?

我知道withCredentials步骤,但是我不能使用它,因为凭据没有存储在Jenkins凭据存储中(而是在运行时作为参数提供).

我在 https://stackoverflow.com/a/42372859/1549950 中找到了这个答案,并尝试了这样的操作:

def secrets = [
    [password: firstPassword, var: 'SECRET'],
    [password: secondPassword, var: 'SECRET'],
    [password: thirdPassword, var: 'SECRET']
]

node() {
    wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: secrets]) {
        // my stages containing steps...
    }
}

其中firstPasswordsecondPasswordthirdPassword是包含我的密码的变量.但是我仍然得到firstPassword ...的内容,在日志输出中显示为纯文本.

我在2.1.2.0版的Jenkins上安装了掩码密码插件. /p>

基本上,我正在搜索以下内容: https://issues.jenkins- ci.org/browse/JENKINS-27486 -票证已解决,但未提供最终实现的示例摘录.

解决方案

我认为您正在寻找https://stackoverflow.com/a/42372859/1549950 and tried it like this:

def secrets = [
    [password: firstPassword, var: 'SECRET'],
    [password: secondPassword, var: 'SECRET'],
    [password: thirdPassword, var: 'SECRET']
]

node() {
    wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: secrets]) {
        // my stages containing steps...
    }
}

Where firstPassword, secondPassword, thirdPassword are variables containing my passwords. But still I get the content of firstPassword... displayed plain text in the log output.

I have the Mask Password plugin installed on my Jenkins in version 2.12.0.

Basically I am searching for something like this: https://issues.jenkins-ci.org/browse/JENKINS-27486 - ticket is resolved, but no sample snippet of final implementation is given.

解决方案

I think you are looking for JENKINS-36007?

这篇关于在不使用WithCredentials的情况下将密码隐藏在Jenkins Pipeline日志输出中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆