Last active
          June 14, 2016 10:45 
        
      - 
      
- 
        Save epishan/886d9e9b50072331f070276fa2ea8b8f to your computer and use it in GitHub Desktop. 
    [groovy] Jenkins generate nested vies
  
        
  
    
      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 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