How to get the XML definition for a view that is inside a folder?


  • Is it possible to dump the view definition XML to stdout ? (The view is in the folder).


  • Jenkins
  • Jenkins LTS
  • CloudBees Jenkins Enterprise (CJE)
  • CloudBees Jenkins Operation Center (CJOC)
  • CloudBees Folders Plugin


In order to get the information of one or more views inside a folder you should use the Jenkins Script Console. For that you should navigate to Manage Jenkins –> Script Console, and run the following script.

import com.cloudbees.hudson.plugins.folder.*

jen = Jenkins.instance

  if(it instanceof Folder){
  println "Folder found"
  if(it instanceof View){
  println "View found"+

void processFolder(Item folder){
def buf = new ByteArrayOutputStream()
def newOut = new PrintStream(buf)
def saveOut = System.out
def viewNameList = []

  println "processing..." +
  if(it instanceof View && != "All") 
    if(!( in viewNameList)){
      viewNameList <<  
      println "View " +

  println buf.toString()
  println " "


This script uses a very simple approach, and gets all the elements existing at root level for your instance, and if the element is a folder, it processes all the views included in it (except for the All view). It is quite straightforward to extend the script in a way that you can process recursively all the elements, or to get the information only for views matching a given pattern or inside a given folder.

See also:

Have more questions? Submit a request


Please sign in to leave a comment.