-
Notifications
You must be signed in to change notification settings - Fork 1
/
shallow.groovy
30 lines (28 loc) · 1.17 KB
/
shallow.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
/*
* List what Items (Folder, FreeStylejob, Pipeline, Multijob, MavenJobs... ) don't
* follow the Shallow Best Practice
*
* Further details:
* - http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getScm--
* - http://javadoc.jenkins.io/plugin/workflow-job/org/jenkinsci/plugins/workflow/job/WorkflowJob.html#getSCMs--
* - http://javadoc.jenkins-ci.org/git/hudson/plugins/git/extensions/impl/CloneOption.html#isShallow()
*/
import hudson.plugins.git.extensions.impl.CloneOption
jenkins.model.Jenkins.instance?.
getAllItems()?.
findAll { try { it.getScm() } catch (groovy.lang.MissingMethodException mme) {} }?.
findAll { it.getScm() instanceof hudson.plugins.git.GitSCM }?.
each {
isShallow = false
if (it.getScm().getExtensions() && it.getScm().getExtensions()?.
find {
it instanceof CloneOption &&
it.isShallow()
}
) {
isShallow = true
}
if (!isShallow)
println "'${it.fullName}' is not using shallow cloning"
}
println '' // Avoid printing the data from the latest closure