Skip to content

Instantly share code, notes, and snippets.

@NicolasGeraud
Created March 4, 2015 14:50
Show Gist options
  • Save NicolasGeraud/0902dee65070d082152b to your computer and use it in GitHub Desktop.
Save NicolasGeraud/0902dee65070d082152b to your computer and use it in GitHub Desktop.
JENKINS - add git branch and rename
import hudson.model.*
import hudson.plugins.git.*
changeBranche(Jenkins.instance.items)
def changeBranche(items) {
println items.size
for (item in items) {
if (item =~ "Feature*") {
print(item.name)
println(item.scm.branches)
if(item.scm.branches.size() == 1) {
if(item.scm.branches[0].name != "*/master") {
println "rename " + item.scm.branches[0].name + " to */master"
item.scm.branches[0].name = "*/master"
}
item.scm.branches.add(new BranchSpec("*/tma/*"))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment