Created
January 30, 2013 00:24
-
-
Save markhuge/4669438 to your computer and use it in GitHub Desktop.
Bulk Jenkins git repo configuration through Groovy interface.
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
| // Loop through Jenkins projects, adding a git repo for any project without a repo defined. | |
| def projects = hudson.model.Hudson.instance; | |
| projects.getItems(hudson.model.Project).each { | |
| proj -> | |
| if (proj.getScm().type == "hudson.scm.NullSCM") { | |
| proj.scm = new hudson.plugins.git.GitSCM("git://path/to/your/repo.git"); | |
| println("Project: " + proj.displayName + " SCM: " + proj.getScm().type); | |
| } | |
| } | |
| // Same as above, but added logic to only update builds where the name contains 'FOO' | |
| def projects = hudson.model.Hudson.instance | |
| projects.getItems(hudson.model.Project).each { | |
| proj -> | |
| if (proj.getScm().type == "hudson.scm.NullSCM" && proj.displayName.contains('FOO')) { | |
| proj.scm = new hudson.plugins.git.GitSCM("git://path/to/your/repo.git"); | |
| println("Project: " + proj.displayName + " SCM: " + proj.getScm().type); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment