forked from cloudbees/jenkins-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
approve-pending-signatures.groovy
40 lines (31 loc) · 1.17 KB
/
approve-pending-signatures.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
/*
Small script that can be used to approve all the pending signatures
To be used with extreme caution
*/
import org.jenkinsci.plugins.scriptsecurity.scripts.*
ScriptApproval sa = ScriptApproval.get();
println "Signatures pending Approval..."
for (ScriptApproval.PendingSignature pending : sa.getPendingSignatures()) {
println "Pending approval : " + pending.signature
}
println "Starting cleanup..."
sa = ScriptApproval.get();
while(sa.getPendingSignatures().size()>0) {
try{
item= sa.getPendingSignatures()[0]
if (!org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.isBlacklisted(item. signature)) {
println "[WARNING] Not approving " + item. signature + " because it is blacklisted"
}
println item.signature
sa.approveSignature(item.signature);
println "Approved : " + item.signature
}catch (Exception e){
println e
}
}
println "Verify that the signatures were approved..."
sa = ScriptApproval.get();
println "Retrieving pending approval signatures..."
for (ScriptApproval.PendingSignature pending : sa.getPendingSignatures()) {
println "Pending approval : " + pending.signature
}