Triggering Gerrit Trigger Plugin On Change To Sub-Directory

1,787 views
Skip to first unread message

Scott Lavender

unread,
Apr 13, 2012, 3:25:19 PM4/13/12
to Repo and Gerrit Discussion
I have a question on using the Gerrit Trigger Plugin with Jenkins. The
plugin help indicated that the following is possible. I have a repo
with to top level directories. I want to trigger two separate Jenkins
jobs to run tests when changes are made to either subdirectory:

compute -> nova
glance

I created two jobs and am having difficulty coming up with the proper
pattern to match so that these changes are detected. I have used this
plugin before with the project name and ** for the branch pattern
successfully. In this case, I want to trigger each job when changes
occur in the master branch within the two subdirectories shown above.
I've tried:

Job: compute.review.glance
Project
Type: Path
Pattern: compute

Branch
Type: Path
Pattern: **/glance

Job: compute.review.nova
Project
Type: Path
Pattern: compute

Branch
Type: Path
Pattern: **/nova


The jobs do not detect changes in the sub directories. I even tried a
trailing /* to no avail. Please, do you have any ideas here?

Magnus Bäck

unread,
Apr 13, 2012, 3:35:29 PM4/13/12
to Repo and Gerrit Discussion
On Friday, April 13, 2012 at 15:25 EDT,
Scott Lavender <slav...@internap.com> wrote:

> I have a question on using the Gerrit Trigger Plugin with Jenkins. The
> plugin help indicated that the following is possible.

Which part of the help? I'm pretty sure what you want to do isn't
possible by just configuring the plugin.

> I have a repo with to top level directories. I want to trigger two
> separate Jenkins jobs to run tests when changes are made to either
> subdirectory:
>
> compute -> nova
> glance
>
> I created two jobs and am having difficulty coming up with the proper
> pattern to match so that these changes are detected. I have used this
> plugin before with the project name and ** for the branch pattern
> successfully. In this case, I want to trigger each job when changes
> occur in the master branch within the two subdirectories shown above.
> I've tried:
>
> Job: compute.review.glance
> Project
> Type: Path
> Pattern: compute
>
> Branch
> Type: Path
> Pattern: **/glance

You're configuring a restriction on the branch name, not the path of
the modified files. The pattern is however of the "path" type, but
that doesn't change what we're matching against.

[...]

--
Magnus Bäck
ba...@google.com

Scott Lavender

unread,
Apr 13, 2012, 3:47:49 PM4/13/12
to repo-d...@googlegroups.com
This is exactly what the plugin help describes:

Then you can optionally provide the name of the specific file path(s) to trigger on. E.g. to only trigger builds if the patch set contains files in a certain folder. The same "pattern types" are available as above. If no file paths are added, all files will trigger a build.

So for example to trigger on all files in any sub-folder called java:

  • Type: Path
  • Pattern: **/java/

Magnus Bäck

unread,
Apr 13, 2012, 4:23:13 PM4/13/12
to repo-d...@googlegroups.com
On Friday, April 13, 2012 at 15:47 EDT,
Scott Lavender <slav...@internap.com> wrote:

> This is exactly what the plugin help describes:
>
> Then you can optionally provide the name of the specific file path(s)
> to trigger on. E.g. to only trigger builds if the patch set contains
> files in a certain folder. The same "pattern types" are available as
> above. If no file paths are added, all files will trigger a build.
>
> So for example to trigger on all files in any sub-folder called java:
>
>

> - *Type:* Path
> - *Pattern:* **/java/

Okay, so there actually is such a feature. It isn't shown in the GUI
examples at https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger
so I assumed it didn't exist.

However, according to what you write in your original post, you're
nevertheless using the branch condition text field when you should be
using the text field for file paths. Reading the source code, this
feature is only enabled if the Gerrit you're running is sufficiently
new (2.2.3+). If it is, there will be a separate set of widgets below
the branch selection widgets to allow you to add and delete file paths
to trigger on.

--
Magnus Bäck
ba...@google.com

Scott Lavender

unread,
Apr 13, 2012, 4:27:32 PM4/13/12
to repo-d...@googlegroups.com
BINGO! I will have to wait on the 2.2.3 release of Gerrit it looks like...

The connected Gerrit's version is a bit old, so not all Gerrit features are enabled. The following featured has been disabled:
  • Trigger on files requires 2.2.3




--

Scott Lavender | Cloud Release Engineer
_____________________________________ _______

Phone 678.554.3403 • Cell 770.361.5940
slav...@internap.com  www.internap.com

INTERNAP ®
connectivity | colocation | managed hosting | cloud

One Ravinia Drive • Suite 1300 • Atlanta • GA • 30346


Jason Axelson

unread,
Apr 13, 2012, 7:24:52 PM4/13/12
to Scott Lavender, repo-d...@googlegroups.com
I think that there is a typo in the Gerrit plugin. When it says it
requires 2.2.3 I think it actually needs 2.3 (which was released last
week).

Jason

Lundh, Gustaf

unread,
Apr 16, 2012, 8:54:04 AM4/16/12
to Jason Axelson, Scott Lavender, repo-d...@googlegroups.com
I have a vague memory which tells me that when we developed the " --file" support for the Gerrit query command (which was needed for this feature to work in the Gerrit Trigger plug-in), we guessed that the next release of Gerrit would be 2.2.3. Hence this would be the first version to support the file filtering in the Jenkins plug-in.

Now, as we now know, the next major release turned out to be Gerrit 2.3 and we ended up with the wrong version warning in Gerrit Trigger plug-in. But don't worry, the Gerrit Trigger guys, Robert Sandell and Tomas Westling, has promised to fix the warning.

Note: If you run a -SNAPSHOT build of Gerrit, all features will be enabled in the Gerrit Trigger plug-in, since we cannot really know what features have been cherry-picked into Gerrit (but with a small warning/notification on the "Manage Jenkins"-page).

/Gustaf

Jason

> Phone 678.554.3403 . Cell 770.361.5940
> slav...@internap.com . www.internap.com


>
> INTERNAP ®
> connectivity | colocation | managed hosting | cloud
>

> One Ravinia Drive . Suite 1300 . Atlanta . GA . 30346

--

Pursehouse, David

unread,
May 9, 2012, 3:48:18 AM5/9/12
to Jason Axelson, Scott Lavender, repo-d...@googlegroups.com
> I think that there is a typo in the Gerrit plugin. When it says it
> requires 2.2.3 I think it actually needs 2.3 (which was released last
> week).
>

This is fixed in version 2.5.2 of the Gerrit Trigger Plugin, which was released earlier this week.


--
David Pursehouse
Configuration Manager
Sony Mobile Communications Japan, Inc.
Reply all
Reply to author
Forward
0 new messages