Jenkins:在Powershell中访问全局密码 [英] Jenkins: Access global passwords in powershell

查看:475
本文介绍了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.

  1. 已安装的凭据绑定插件,环境注入器插件,掩码密码插件,Hudson PowerShell插件
  2. 在管理凭据中以gluser身份创建了全局密码条目
  3. 在我的构建中,我进行了一个powershell调用,其中定义了构建环境,用于将密码作为环境变量注入到构建中,并检查全局密码.
  4. 以下任何一项都不会让我在我的Powershell脚本中引用全局密码
    $env:gluser
    $gluser
  1. Installed Credentials Binding Plugin, Environment Injector Plugin, Mask Passwords Plugin, Hudson PowerShell plugin
  2. Created a global password entry within manage credentials as gluser
  3. 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.
  4. 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
  1. 点击添加.
  2. 输入(环境变量的)名称和密码.

  • 工作-> 配置
  • 构建环境下

  • Job -> Configure
  • Under Build Environment

    1. 检查将密码作为环境变量注入到内部版本.
    2. 检查全局密码.
    3. 检查掩码密码参数.
    1. check Inject passwords to the build as environment variables.
    2. Check Global passwords.
    3. Check Mask password parameters.

    • 管理Jenkins -> 管理凭据
    1. 点击添加凭据(无域).
    2. 选择具有密码的用户名秘密文本.
    3. 输入用户名密码秘密.
    1. Click Add Credentials (without domain).
    2. Select Username with password OR Secret text.
    3. Enter Username and Password OR Secret.

  • 工作-> 配置
  • 构建环境下

  • Job -> Configure
  • Under Build Environment

    1. 选中使用秘密文本或文件.
    2. 绑定下,单击添加.
    3. 选择用户名和密码秘密文本.
    4. 输入要保留凭据值的变量名称.
    5. 选择特定凭据单选按钮.
    6. 从下拉列表中选择您配置的凭据
    1. Check Use secret text(s) or file(s).
    2. Under Bindings, click Add.
    3. Select Username and password OR Secret text.
    4. Enter Variable name that you want to hold your credentials value.
    5. Select Specific credentials radio button.
    6. 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
      where VAR_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屋!

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