Jenkins 2 - How to get user role (Role Strategy Plugin) from Jenkins Workflow - Pipeline Plugin
问题 I would like to access the user role/roles, configured in Role Strategy Plugin in a Jenkins 2 pipeline (workflow): node { // Get the user Role } 回答1: import jenkins.model.Jenkins import com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy import com.michelin.cio.hudson.plugins.rolestrategy.Role node { stage('Get Role') { def user = Jenkins.getInstance().getUser( Jenkins.getInstance().getItemByFullName(env.JOB_BASE_NAME, Job.class).getBuildByNumber(env.BUILD_ID as int)