简体   繁体   中英

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..

Jenkins.instance.getItem('my_folder').getView('MyNewView').setIncludeRegex('.*NewView.*'

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

doSubmitDescription(...?)

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 getView('MyNewView').getURL()+"/submitDescription...";

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM