2014-10-29 187 views
1

使用Mask密碼插件我在Manage Jenkins中添加了變量 - > Mask Passwords - 全局名稱/密碼對。 如何通過動態選擇參數中作業的參數化部分中的Groovy腳本獲取它? (在我的Groovy腳本我需要指定密碼來獲取信息,我想隱藏一些東西)如何在Groovy腳本中獲取Jenkins Mask密碼變量

+0

所以你需要在你的groovy腳本中指定密碼來填充選項以顯示用戶供他們選擇? – KeepCalmAndCarryOn 2014-10-29 19:49:17

+0

我嘗試爲用戶提供git標籤選擇:'def gitURL =「http:/ username:[email protected]」 def command =「git ls-remote -t​​ $ gitURL」 def proc = command.execute ) proc.waitFor() 如果(proc.exitValue()!= 0){ 的println 「錯誤,$ {} proc.err.text」 System.exit(-1) } 高清標籤= proc.in.text.readLines()。collect { it.replaceAll(/ [a-z0-9] * \ trefs \/tags \ //,'') } 標籤' – fred05 2014-10-30 09:58:38

+0

這個插件是做什麼的你要? https://wiki.jenkins-ci.org/display/JENKINS/Git+Parameter+Plugin – KeepCalmAndCarryOn 2014-10-30 11:14:12

回答

0

這裏是如何使用它的哈希來解密密碼:

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

我敢肯定還有其他的如何找到密碼的散列,但它的一種方式來查找credentials.xml

相關問題