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)
如下图所示:
运行效果: