【问题标题】:How to get Jenkins Mask Password variable in Groovy script如何在 Groovy 脚本中获取 Jenkins 掩码密码变量
【发布时间】:2014-10-29 17:10:03
【问题描述】:

使用 Mask Password 插件,我在 Manage Jenkins -> Mask Passwords - 全局名称/密码对中添加了变量。 如何在动态选择参数的作业参数化部分通过 Groovy 脚本获取它? (在我的 groovy 脚本中,我需要指定密码才能获取信息,我想隐藏它)

【问题讨论】:

  • 所以您需要在您的 groovy 脚本中指定密码以填充选项以向用户显示供他们选择?
  • 我尝试为用户选择 git 标签:'def gitURL = "http:/username:how2maskThisPass@giturl.git" def command = "git ls-remote -t​​ $gitURL" def proc = command.execute() proc.waitFor() if ( proc.exitValue() != 0 ) { println "Error, ${proc.err.text}" System.exit(-1) } def tags = proc.in. text.readLines().collect { it.replaceAll(/[a-z0-9]*\trefs\/tags\//, '') } tags'
  • 这个插件能做你想做的事吗? wiki.jenkins-ci.org/display/JENKINS/Git+Parameter+Plugin
  • 在这种情况下很有用

标签: groovy jenkins


【解决方案1】:

以下是使用哈希值解密密码的方法:

hashed_pw='your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J'
passwd = hudson.util.Secret.decrypt(hashed_pw)
println(passwd)

我确信还有其他方法可以找到密码的哈希值,但有一种方法可以在 credentials.xml 中查找它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-06
    • 1970-01-01
    • 1970-01-01
    • 2018-12-19
    • 1970-01-01
    • 2020-05-03
    • 2011-10-10
    • 2019-10-21
    相关资源
    最近更新 更多