wom wom - 1 month ago 7x
Groovy Question

How to set a Views description in Groovy

I'm dynamically creating a view via Groovy with..

Jenkins.instance.getItem('my_folder').addView(new ListView('MyNewView')

This works great; and I then add a filter to this view via..


Which also works wonderfully. How would I then programmatically set the views description? I assume there's some combination I can do with


But I haven't been able to sus it out.. Any help would be appreciated.

My current plan is to work around this by posting to

but it should be much cleaner than that..


If you want to update the view's description, here is the line you are looking for:

import org.kohsuke.stapler.StaplerRequest
import org.kohsuke.stapler.StaplerResponse

Jenkins.instance.getView('MyNewView').doSubmitDescription([ getParameter: { return "My description"; }] as StaplerRequest, [ sendRedirect: { return; } ] as StaplerResponse)