-
Notifications
You must be signed in to change notification settings - Fork 0
/
FolderTree.groovy
60 lines (46 loc) · 1.23 KB
/
FolderTree.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Print folders and subfolders
*
* Configuration:
* DEBUG - print debug info
* PRINTFOLDERS - print found subfolders in folders
* PRINTJOBS- print found subjobs in folders
*/
import com.cloudbees.hudson.plugins.folder.*
List<Item> allJobs = Jenkins.instance.getAllItems();
boolean DEBUG = false;
boolean PRINTFOLDERS = true;
boolean PRINTJOBS = false;
for(int i = 0; i < allJobs.size() ; i++){
def item = allJobs.get(i);
if(DEBUG){
println("all #"+i+": "+item.fullName);
if(item instanceof Folder){
println "IS FOLDER!";
}
}
if(item instanceof Folder){
println ("-" + item.fullName);
printFolder(item,1,PRINTFOLDERS,PRINTJOBS);
println();
}
}
void printFolder(Item folder,count,printF,printJ){
List<Item> subs = folder.getItems().each{
if (it instanceof Folder){
if(printF){
printBrackets(count);
println(":F: " + it.fullName)
}
printFolder(it,count++,printF,printJ);
}else if(printJ){
printBrackets(count);
println(":J: " + it.fullName)
}
}
}
void printBrackets(count){
for(int x = 0; x < count ; x++){
print("--");
}
}