好的,再经过几次搜索后,我发现了源代码(https://github.com/jenkinsci/role-strategy-
plugin/tree/master/src/main/java/com/michelin/cio/hudson/plugins/rolestrategy)
经过进一步的阅读和一些玩耍之后,我想到了这个…
import com.michelin.cio.hudson.plugins.rolestrategy.*def result = ["-- Please Select --"]def authStrategy = jenkins.model.Jenkins.instance.getAuthorizationStrategy()if(authStrategy instanceof RolebasedAuthorizationStrategy){ def currentUser = jenkins.model.Jenkins.instance.getAuthentication().getName(); def roleMap= authStrategy.roleMaps.get("globalRoles") def sids= roleMap.getSidsForRole("Manage_Dev") if(sids != null && sids.contains(currentUser)) { result.add("dev1") ... } sids= roleMap.getSidsForRole("Manage_Test") if(sids != null && sids.contains(currentUser)) { result.add("tst1") ... } ...}return result
哪个对我有用。当您知道如何时就轻松!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)