Created
July 29, 2019 06:37
-
-
Save phaneesh/80ea58a37b5fe1b597e4d5d426926561 to your computer and use it in GitHub Desktop.
Get Branch invalid/non-standard configuration from Jenkins
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
import hudson.model.* | |
import hudson.maven.MavenModuleSet | |
import hudson.tasks.* | |
import hudson.plugins.git.GitSCM | |
//List valid branches that can be built | |
def validBranches = ["develop","master"] | |
Hudson.instance.items.each { | |
if(it.getScm() instanceof GitSCM) { | |
Set branchNames = [] | |
it.getScm().getBranches().each { b -> | |
if(!validBranches.contains(b.getName().replaceAll("\\*","").replaceAll("/", ""))) { | |
branchNames.add(b.getName().replaceAll("\\*","").replaceAll("/", "")) | |
} | |
if(!branchNames.isEmpty()) { | |
println(it.name + " - " +branchNames) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment