Last active
August 24, 2017 10:42
-
-
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.
This file contains hidden or 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
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() | |
} | |
} |
I'm encountering the same problem as @Winglet. Has anyone found an alternative method to set this property?
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
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