Jenkins:在 powershell 中访问全局密码 [英] Jenkins: Access global passwords in powershell
本文介绍了Jenkins:在 powershell 中访问全局密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在 powershell 中将 jenkins 全局密码作为环境变量访问.我做了以下工作.不知道我还缺少什么.
I am having trouble accessing the jenkins global password as an environment variable in powershell. I have done the following. Not sure what else I am missing.
- 已安装凭据绑定插件、环境注入器插件、掩码密码插件、Hudson PowerShell 插件
- 在作为 gluser 的管理凭据中创建了一个全局密码条目
- 在我的构建中,我有一个 powershell 调用,构建环境定义为将密码作为环境变量注入构建并检查全局密码.
- 以下内容均无法让我在我的 powershell 脚本中引用全局密码
$env:gluser
$gluser
他们似乎都没有让我在 Jenkins 的 powershell 调用中访问全局密码.有人可以帮忙吗?
None of them seem to let me access the global password within powershell call from Jenkins. Could someone please help?
推荐答案
不要混淆 EnvInject 插件 和 凭据绑定插件.两者做的事情完全不同,但是两者都允许全局管理密码,但又有所不同.
Don't confuse EnvInject plugin and Credentials Binding plugin. The two do quite different things, however both allow the manage passwords globally, yet differently.
- 管理 Jenkins -> 配置系统
- 在全局密码下
- 点击添加.
- 输入名称(环境变量)和密码.
- 检查将密码作为环境变量注入构建.
- 检查全局密码.
- 检查屏蔽密码参数.
- 管理 Jenkins -> 管理凭据
- 点击添加凭据(不带域).
- 选择用户名和密码或密文.
- 输入用户名和密码或秘密.
- Click Add Credentials (without domain).
- Select Username with password OR Secret text.
- Enter Username and Password OR Secret.
- 勾选使用秘密文本或文件.
- 在绑定下,点击添加.
- 选择用户名和密码或密文.
- 输入要保存凭据值的变量名称.
- 选择特定凭据单选按钮.
- 从下拉列表中选择您配置的凭据
- Check Use secret text(s) or file(s).
- Under Bindings, click Add.
- Select Username and password OR Secret text.
- Enter Variable name that you want to hold your credentials value.
- Select Specific credentials radio button.
- Select your configured credentials from the drop-down
- 像访问任何其他环境变量一样访问这些:
$env:VAR_NAME
其中VAR_NAME
是环境变量名称(即 EnvInject 方式的第 2 步,或 Credentials Binding 方式的第 4 步)
- Access these as you would any other environment variable:
$env:VAR_NAME
whereVAR_NAME
is the environment variable name (i.e. step 2 from EnvInject way, or step 4 from Credentials Binding way)
EnvInject 与凭据绑定
- EnvInject 密码将在环境变量列表中显示加密.
- EnvInject 密码将在控制台输出中显示星号 (*****).
- EnvInject 密码使用与全局配置相同的变量名,因此您必须记住该全局变量名.
| - CB 密码以纯文本形式显示在环境变量列表中.
- CB 密码未在控制台输出中加星标.
- CB 密码可以从下拉列表中绑定到您想要的作业中的任何变量名称,因此您不必记住该全局变量名称.
| - 凭据绑定实际上更多地用于投标凭据文件,例如证书和密钥,而不是密码值.
用户名与密码与秘密文本.
- 前者以
username:password
的形式提供. - 后者只是
秘密
.
- The former is available in the form
username:password
. - The latter is just
secret
.
这篇关于Jenkins:在 powershell 中访问全局密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文