jenkins - Jenkins Pipeline 在 Plaintex 中显示密码
问题描述
我正在从credentials
插件中检索用户名密码。然后将这些值保存为环境变量。我在管道的后期阶段使用密码,在sh
块中作为curl
. 此时密码以明文形式显示在构建日志中。有没有办法避免这种情况?我假设通过使用credentials
插件密码将被屏蔽。
pipeline {
stages {
stage ('One') {
steps {
withCredentials([userNamePassword(credentialsId: 'my_cred', userNameVariable: 'User_Name', passwordVariable: 'Password')]){
env.User_Name = User_Name
env.Password = Password
}
}
}
stage ('Two') {
sh '''
curl -v -u ${User_Name}:${Password} ...
'''
}
}
}
注意:我正在使用将curl
文件上传到远程主机。
解决方案
我最终使用了块curl
内部withCredentials
。
withCredentials([userNamePassword(credentialsId: 'my_cred', userNameVariable: 'User_Name', passwordVariable: 'Password')]){
sh '''
curl -v -u ${User_Name}:${Password} ...
'''
}
推荐阅读
- javascript - 在javascript中附加对象时for循环不起作用
- java - 弹出窗口显示 IllegalStateException
- php - 如何在我的 Joomla 网站中删除 Zendesk Live Chat?
- php - 这个 php 登录系统安全吗/
- powershell - Rundeck 作业失败导致详细输出
- sql - 每天将日期添加到特定日期
- python - 如何使用 Python 向现有 PDF 添加高亮注释
- reactjs - 如何使用 Django Rest 管理移动和 Web 身份验证并做出反应/反应本机?
- c++ - 在 C++ 中对字符串使用#define
- python - 如何从不同的文件中提升 Tkinter 框架?