1.添加Active Choices Parameter參數GroupList,Groovy Script內容如下:
import hudson.model.User def cuser=User.current().getId() //獲取當前登錄用戶id def obj_groups = """ /usr/local/python3/bin/python3 /script/SaltAPI2.py 10.10.4.21 http://auto.x.com/ADDGroup_GetGroup.ps1 $cuser""".execute().text.readLines() obj_groups .each{ println it }
/usr/local/python3/bin/python3 /script/SaltAPI2.py 10.10.4.21 http://auto.x.com/ADDGroup_GetGroup.ps1 $cuser運行結果輸出如下:
組1(group1@x.com)
組2(group2@x.com)
組3(group3@x.com)
2.添加Active Choices Reactive Parameter參數GroupMember,Groovy Script內容如下,然后關聯上一步的參數GroupList
//GroupList=GroupList GroupName= GroupList.split('(')[0] def obj_members = "/usr/local/python3/bin/python3 /script/SaltAPI2.py 10.10.4.21 http://auto.x.com/ADDGroup_GetMember.ps1 $GroupName".execute().text.readLines() obj_members .each{ println it }
/usr/local/python3/bin/python3 /script/SaltAPI2.py 10.10.4.21 http://auto.x.com/ADDGroup_GetMember.ps1 $GroupName運行輸出結果如下:
張三(zhangsan)
李四(lisi)
王五(wangwu)
如下圖所示:
運行效果: