Skip to content

Instantly share code, notes, and snippets.

@TheDauthi
Last active May 29, 2017 06:15
Show Gist options
  • Save TheDauthi/11316074 to your computer and use it in GitHub Desktop.
Save TheDauthi/11316074 to your computer and use it in GitHub Desktop.
Gets a list of SCMs in use by Jenkins. Displays the list of remote configs.
import hudson.model.*
// Only detect jobs that have the SCM property available
jobs = Hudson.instance.getAllItems().findAll {
job -> job.hasProperty("scm")
}
// Cheap formatting hack =)
maxWidth = Collections.max(jobs.collect { job -> job.fullName.length() })
format = "%-" + (maxWidth + 4) + "s"
for(job in jobs)
{
if(job.scm.hasProperty("userRemoteConfigs")) {
urls = job.scm.userRemoteConfigs.collect {
remote -> remote.url
}
println sprintf(format, job.fullName) + urls
}
else
println sprintf(format, job.fullName) + "[]"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment