How to create a new folder inside Jenkins view with groovy script

9,218 views
Skip to first unread message

Srini

unread,
Mar 16, 2015, 1:46:29 PM3/16/15
to job-dsl...@googlegroups.com
Hi , 

We have a groovy script which creates a new folder and creates a job inside the newly created folder. The newly created folder is showing up in Jenkins "All" view. My requirement is instead of "All" view , newly created folder to be showed up in a view that is available in my Jenkins i.e "Test" . 

Snippet of code that am using in groovy : 

This is creating a folder in view "All"

folder {
name "${project}"
}

job {
name "${project}/${project}Web"
}


Thanks,
Srini

Daniel Spilker

unread,
Mar 20, 2015, 10:55:48 AM3/20/15
to job-dsl...@googlegroups.com
Hi,

to create a view containing a folder, do this:

folder('my-folder') {
}

listView('my-view') {
  jobs {
    name('my-folder')
  }
  columns {
    status()
    name()
  }
}

It's a bit unfortunate that the method in listView is called jobs, but it also accepts folders.

Daniel

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/33564acb-60f8-4a03-b283-b6b1699112c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Srini

unread,
Feb 17, 2016, 11:34:41 AM2/17/16
to job-dsl-plugin
Hi Daniel, 

As advised I tried the below code but still the same problem. The below code is creating new folder and view but the folder is not moved into the view that got created. Please advise. 

job {
	name "Test"
	description 'Test' 
folder('my-folder') {
}	
listView('my-view') {
  jobs {
    name('my-folder')
  }
}				
				
				
}	

Thanks,
Srini

Victor Martinez

unread,
Feb 17, 2016, 3:33:05 PM2/17/16
to job-dsl-plugin
Can you check whether the above snippet is generated accordingly with the below playground url?


if you do those steps manually in your jenkins instance, how is the xml view?Does it match with the above xml?

Cheers

karthik m

unread,
Dec 7, 2016, 8:51:24 AM12/7/16
to job-dsl-plugin
Hi,

Do we have any groovy snippet to create view and available jobs to that view.Please post that groovy snippet.

Thanks,
Karthik.

Sai Kishore

unread,
Dec 7, 2016, 9:26:51 AM12/7/16
to job-dsl...@googlegroups.com
we can use list view as below

listView('view_name) {
    description('All unstable jobs for project A')
    filterBuildQueue()
    filterExecutors()
    jobs {
        name('release-projectA')
        regex(/project-A-.+/)
    }
}

This will create a new tab with the 'View_name' and contains the jobs you mentioned .


Thanks
Sai kishore Amirishetty



--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/067b23b3-9795-411b-8ef8-31f0e3160df6%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages