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
- Installed Credentials Binding Plugin, Environment Injector Plugin, Mask Passwords Plugin, Hudson PowerShell plugin
- Created a global password entry within manage credentials as gluser
- In my build, I have a powershell call with the build environment defined for inject passwords to the build as environment variables and checked for global passwords.
- None of the following get me to reference the global password in my powershell scripts
$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 -> 配置系统
- 在全局密码下
- Manage Jenkins -> Configure System
- Under Global Password
- 点击添加.
- 输入(环境变量的)名称和密码.
- 检查将密码作为环境变量注入到内部版本.
- 检查全局密码.
- 检查掩码密码参数.
- check Inject passwords to the build as environment variables.
- Check Global passwords.
- Check Mask password parameters.
- 管理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密码可以从下拉菜单中绑定到您想要在作业中使用的任何变量名,因此您不必记住该全局变量名.
| - 凭证绑定实际上更适合于竞标凭证文件,例如证书和密钥,而不是密码值.
- EnvInject passwords will show encrypted in list of environment variables.
- EnvInject passwords will show starred (*****) in console output.
- EnvInject passwords use the same variable name as the global configuration, so you have to remember that global variable name.
| - CB passwords are shown plain text in list of environment variables.
- CB passwords are not starred in console output.
- CB passwords can be bound to any variable name you want in the job from a dropdown, so you don't have to remember that global variable name.
| - Credentials Binding is really more for biding credential files, like certificates and keys, rather than password values.
带有密码和密文的用户名.
- 前者的形式为
username:password
. - 后者就是
secret
.
- The former is available in the form
username:password
. - The latter is just
secret
.
这篇关于Jenkins:在Powershell中访问全局密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文