Home > Net >  Update Jenkins view automatically
Update Jenkins view automatically

Time:11-05

I am working on some automation and I need to update the view programmatically.

UseCase: I have a jenkins view where I add all the jobs based on the release number and I do that by giving regular expression here- enter image description here

I want to update this regular expression through script.

Is it possible to do the same through a groovy script?

CodePudding user response:

Here is how you can update the regex filters from Groovy. I have come up with the following with the limited information you have given. You may have to improve it based on the options you have enabled in your view.

def viewObj = Jenkins.instance.getView("VIEWNAME")
List<hudson.views.ViewJobFilter> jobFilters = new ArrayList<>()

jobFilters.add(new hudson.views.RegExJobFilter('.*NEWREGEX', "includeMatched", "NAME"))
viewObj.setJobFilters(jobFilters)
  • Related