forked from cloudbees/jenkins-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Check-Item-Permission-perUser.groovy
43 lines (39 loc) · 1.05 KB
/
Check-Item-Permission-perUser.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Author: Alex Taylor
Since: June 2019
Description: This script will get all items and then print every user's permission on the item itself
*/
iimport org.acegisecurity.*
import hudson.security.Permission;
import hudson.security.PermissionGroup;
import hudson.security.ACLContext;
import hudson.model.User
import jenkins.security.*
import java.util.Date
Set failedUsers = []
for (i in Jenkins.instance.allItems) {
println(i.getFullDisplayName())
for (u in User.getAll()){
if (failedUsers.contains(u)){
break;
}
def permissionsList = u.getId().toString() + ": ";
//READ, CONFIGURE, CREATE, DELETE, UPDATE
for(p in permissions.values()){
try{
if(i.getACL().hasPermission(u.impersonate(), Item.(p.name()))){
permissionsList = permissionsList + p.toString() + " "
}
}
catch(Exception e){
println("Failed to impersonate user: " + u.getId())
failedUsers.add(u);
break;
}
}
println(permissionsList)
}
}
enum permissions{
READ, CONFIGURE, CREATE, DELETE
}