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

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

他们似乎都没有让我在 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 -> 配置系统
  • 全局密码
  1. 点击添加.
  2. 输入名称(环境变量)和密码.

  • 作业 -> 配置
  • 构建环境

    1. 检查将密码作为环境变量注入构建.
    2. 检查全局密码.
    3. 检查屏蔽密码参数.

    • 管理 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.

  • 作业 -> 配置
  • 构建环境

    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 密码可以从下拉列表中绑定到您想要的作业中的任何变量名称,因此您不必记住该全局变量名称.
      |
    • 凭据绑定实际上更多地用于投标凭据文件,例如证书和密钥,而不是密码值.

    用户名与密码与秘密文本.

    • 前者以username:password的形式提供.
    • 后者只是秘密.
    • The former is available in the form username:password.
    • The latter is just secret.

    这篇关于Jenkins:在 powershell 中访问全局密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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