简体   繁体   English

如何在Groovy中设置视图描述

[英]How to set a Views description in Groovy

I'm dynamically creating a view via Groovy with.. 我正在通过Groovy使用动态创建视图。

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..."; 我当前的计划是通过发布到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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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