Groovy web console

subscribe to the feed Subscribe
to this
site
Get git Feature Branches (via #groovywebconsole)
tweet this snippet Tweet
this
script

Get git Feature Branches

Published 2 months ago by Michael Rudiger with tags jenkins git
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
getFeatureBranches("blah")

def getFeatureBranches(url) {
    def featureBranchJobNames = []
    def branchlist= ["refs/heads/feature/test", "refs/heads/develop", "refs/heads/feature/WIN-5", "refs/heads/master"]
    branchlist.each {
        println("Found branch" + it)
        def branchName = it
        if(branchName.contains('/feature/')) {
            println(it + " is a feature branch!")
            def jobName = "feature-" + it.substring(it.lastIndexOf("/") + 1)
            println("JobName will be " + jobName)
            featureBranchJobNames.add(jobName)
        }
    }
    return featureBranchJobNames
}