Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a view across folders in Jenkins?

In our previous Jenkins setup we used a combination of the Build Monitor Plugin and the View Job Filters Plugin to create a screen showing our last 18 builds.

With our new setup we decided to break the builds into multiple folders, some of which are just simple folders, one is a dynamic folder pointing to Bitbucket. We would now like to re-create the same kind of view: show the 18 most recent builds across all of our builds.

If I just select the top folders in the configuration of the build monitor view, then no builds appear - no matter if I set the "Recurse in subfolders" option or not. I need to manually select individual jobs, which is not something we want to maintain in the long run.

If I use a regular expression match, then it includes jobs from other folders that are not selected.

There is also nothing I can find in the "Add Job Filter" menu that seems to allow me to filter jobs to come from within a selection of folders.

I can create multiple build monitor views, one for each folder - but that doesn't give me the last 18 builds over all.

Is there a way to create a build monitor with a number of most recent builds across multiple folders?

like image 881
Peter Becker Avatar asked Nov 28 '16 04:11

Peter Becker


2 Answers

I figured out that you can use a regular expression to include jobs, assuming that all the jobs are contained in a single subfolder, my-jobs, you can do:

my-jobs/.*

to include only jobs within those folders.

Further, you can restrict this more by adding job filter matches which let you exclude other jobs if it starts including more jobs than you wanted.

like image 102
Jake Avatar answered Nov 13 '22 16:11

Jake


For me on the latest version of Jenkins at time of writing (2.240), for the view to pick up jobs in subfolders, I had to tick Recurse in subfolders else the regular expressions would not match any jobs in folders.

Combined with Use a regular expression to include jobs into the view and a regular expression such as the one below, I was able to get the view to show jobs within a folder:

/MyFolder/.*

I suspect that if you wanted to include jobs from multiple folders, you could do so with a regular expression such as:

(/MyFolder/.*)|(OtherFolder/.*)
like image 25
Daniel Avatar answered Nov 13 '22 15:11

Daniel