Hi Oleg, Thank you for fast response :) On Friday, November 11, 2016 at 7:24:05 PM UTC+2, Oleg Nenashev wrote: > > Hi Stas, > > You do not impersonate within the script, hence your code actually checks > if the *current user* has *ADMINISTER* permission fo *user u*. > > Example of a working code: > https://github.com/jenkinsci/ownership-plugin/blob/0c8e5e65a78567bb152ee1c906620c9c66ea8820/src/main/java/com/synopsys/arc/jenkins/plugins/ownership/util/userFilters/AccessRightsFilter.java#L55-L74 > > . You will need to replace the checked item by > Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) > > четверг, 10 ноября 2016 г., 12:29:56 UTC+1 пользователь Stas Roshkolets > написал: >> >> Hello, I am trying to write Groovy script that will identify users that >> they are assigned as admins in Jenkins : >> >> import jenkins.model.Jenkinsimport hudson.model.Userimport >> hudson.security.Permission >> >> allUsers = User.getAll() >> adminList = []for (u in allUsers) { >> if (u.hasPermission(Jenkins.ADMINISTER)) { >> // if (u.canDelete()) { >> adminList.add(u) >> }} >> println allUsers >> println adminList >> >> >> Both lists allUsers, adminList print all users in the system... >> >>
-- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/8f63f1e0-1083-4958-93b6-622a06d3cc7a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
