2
votes

I want my code review job to ignore changes that came from other Jenkins job, like my release job for example. Those commits can be identified either by the committing user (preferable) or the commit comment string (also acceptable).

Basically I have the same problem as the user who asked Ignore Jenkins job if commit message starts with a given string, except that I'm not using the Git plugin with polling. Instead I'm using the Gerrit Trigger plugin, which gets triggered on each new change set.

I believe the below screenshot includes the relevant configuration of the GT plugin.

I have searched around the web, but I couldn't find how to accomplish this. I found this kind of configuration for the Git plugin, but I can't use it since we're using Gerrit and so we need pre-commit changeset triggering rather than polling.

Trigger on "Patchset Created", "Draft published"

3

3 Answers

3
votes

Gerrit Trigger provides a group of variables in which you can find committer's name, commit message, etc. The solution I'm using is to test the values of these variables and end the build job if the test passes. But there might be a problem if you are using Jenkins V2.3 or later. Some of the variables cannot be accessed via $ in shell. You can refer to Jenkins V2.3 release notes to solve this issue. You could press the question mark right to Gerrit event to see the list of variables.

2
votes

One suggested approach was to use the "ci skip" plugin.

I set up my release jobs to include [ci skip] in their commit messages.

When using it I found it actually still triggers a build. However, the build is exited as "Not Built", just after checking our the commit. This means the build still clutters my build history, and it still consumes resources to fetch and rev-parse etc, so it is a less preferable solution to me.

While this solves my immediate problem, I will happily accept other answers since I'm not entirely happy with this one.

2
votes

Actually, you can skip job execution using regex pattern in Gerrit topic configuration.

For example, you may not allow triggering job for change which topic has WIP word. This is possible using following regex ^((?!WIP).)*$.

Here is an example how it trigger is implemented in our pipeline

Gerrit trigger configuration:

enter image description here

Hope it will help.