-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*** BEGIN META { | ||
"name" : "add git clean before checkout", | ||
"comment" : "This script will add git clean after checkout to all Jenkins items ", | ||
"parameters" : [], | ||
"authors" : [ | ||
{ name : "Zamir Ivry - [email protected]" } | ||
] | ||
} END META**/ | ||
|
||
for(item in Hudson.instance.items) { | ||
println item.getSCMs(); | ||
for(scm in item.getSCMs()) | ||
{ | ||
if(scm instanceof hudson.plugins.git.GitSCM) | ||
{ | ||
es = scm.getExtensions() | ||
if(hasCheckOutPlugin(es, b)) | ||
{ | ||
println "already exists in " + item.getName() | ||
continue; | ||
} | ||
println "adding clean to " + item.getName() | ||
es.add(new hudson.plugins.git.extensions.impl.CleanCheckout()) | ||
item.save() | ||
} | ||
} | ||
} | ||
|
||
private java.lang.Boolean hasCheckOutPlugin(es, java.lang.Boolean b) { | ||
for(s in es) { | ||
if(s instanceof hudson.plugins.git.extensions.impl.CleanCheckout) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |