Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/zivry/jenkins-scripts int…
Browse files Browse the repository at this point in the history
…o zivry-master
  • Loading branch information
imod committed Jul 24, 2019
2 parents 2ff8139 + c14e444 commit 1961eb1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scriptler/addGitCleanCheckout.groovy
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;
}

0 comments on commit 1961eb1

Please sign in to comment.