pipeline{
    agent any
    stages{
        stage("任务申请"){
            steps{
                wrap([$class: 'BuildUser']) {
                   script {
                   //获取当前登录用户账户、姓名、邮箱
                   Applier_id = "${BUILD_USER_ID}"
                   }
                   script{
                    println Applier_id   
                    def auths = Jenkins.instance.securityRealm.loadUserByUsername(Applier_id)
                                .authorities.collect{a -> a.authority}
                    //获取用户所属组
                    println auths

                   }
                }
            }
        }
        




    }
}

 

Active choices parameter根据用户所属不同组返回不同结果:

import hudson.model.User
import jenkins.model.*
//def userid = User.current().id
def auths = Jenkins.instance.securityRealm.loadUserByUsername(User.current().id)
        .authorities.collect{it -> it.authority}
if("IT_Group" in auths){
    return [
            '查询邮箱管理员:selected',
            '查询用户绑定的邮箱'
    ]
}else {
    return [
            '查询邮箱管理员:selected',
    ]
}

 

相关文章:

  • 2022-12-23
  • 2022-02-19
  • 2022-01-01
  • 2022-12-23
  • 2021-10-29
  • 2021-12-05
  • 2022-12-23
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案