Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scrobbleme/5772342 to your computer and use it in GitHub Desktop.
Save scrobbleme/5772342 to your computer and use it in GitHub Desktop.
This snippets configures all your Jenkins jobs, which use Git as SCM to use shallow clones. This is usefull to save storage and speed up clone. You can execute this scripts with Jenkins build in Groovy console.
import jenkins.model.*
for(item in Jenkins.instance.items) {
if(item.scm instanceof hudson.plugins.git.GitSCM){
println("JOB : "+item.name)
print("useShallowClone: " + item.scm.useShallowClone)
item.scm.useShallowClone=true
println(" => "+item.scm.useShallowClone)
println("\n=======\n")
item.save()
}
}
@zerogvt
Copy link

zerogvt commented Apr 28, 2016

I think the model has changed since. This is no longer working
groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: useShallowClone for class: hudson.plugins.git.GitSCM

@rpdelaney
Copy link

I'm encountering the same problem as @Winglet. Has anyone found an alternative method to set this property?

@gaborrebner
Copy link

gaborrebner commented Aug 24, 2017

I have the same problem and no solution to this.
When you want to disable the Shallow-Clone in all jobs, you can use
find -maxdepth 2 -name "config.xml" -exec sed -i 's#<shallow>true#<shallow>false#g' {} \;
on a linux based system in JENKINS_HOME\jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment