• Jenkins Active Parameters之Groovy Script(获取具有管理员权限的组+组成员)


    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)

    如下图所示:

    运行效果:

  • 相关阅读:
    [#]
    Windows 下配置 ApacheBench (AB) 压力测试
    [转载]
    Nginx 系列教程
    设置外接显示器顺序(哪个在左,哪个在右)的方法
    [.Net] 一句话Linq(递归查询)
    [Xamarin]
    [SVN]
    [SQL SERVER]
    [Oracle]
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/13361222.html
Copyright © 2020-2023  润新知