Skip to content

Instantly share code, notes, and snippets.

@epishan
Last active June 14, 2016 10:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epishan/886d9e9b50072331f070276fa2ea8b8f to your computer and use it in GitHub Desktop.
Save epishan/886d9e9b50072331f070276fa2ea8b8f to your computer and use it in GitHub Desktop.
[groovy] Jenkins generate nested vies
import jenkins.model.*
import hudson.model.ListView
import hudson.model.*
import hudson.plugins.nested_view.*
def name_parent = 'GO'
def name_component = 'Component1_VIEW'
def name_repo = 'repo_regex'
def viewObj = Jenkins.instance.getView(name_parent) //lvl 1
//delete view if exists
viewObj.getViews().each {
println "Views under GO: " + it.name
if(it.name == name_component){
println "DELETE view Name: " + it.name;
viewObj.deleteView(it)
}
}
def newNested = new NestedView(name_component) //lvl 2
def listViewNames = ["build", "deploy", "deploy_container", "build_image"]
listViewNames.each {
def newViewObj = new ListView(it,newNested)
newViewObj.setIncludeRegex( name_parent + '\\.' + name_repo + '\\.' + it + '\\..*')
newNested.addView(newViewObj)
}
newNested.setOwner(viewObj)
viewObj.addView(newNested)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment