Gerrit + Jenkins: How to trigger an action after the merge, or is the review abandoned?

advertisements

I current trigger Jenkins builds on a git push to refs/for/ via the gerrit trigger in Jenkins (at the start of a review). This produces a build that is suitable for testing and verification prior to review completion. When the review is done (and any necessary rebasing is finished) the review is marked complete and this triggers the final merge of the code to Git (fast-forward only).

This works, but I'd prefer to park the build artifacts from Jenkins somewhere special until the review is finally merged, at which time that last build's artifacts go somewhere else (if the review is abandoned those artifacts would instead get purged).

I thought I might create a special post-merge job in Jenkins and have it trigger on a merge, but since I want to trigger such a job if a branch is abandoned I don't think the merge trigger will cut it. Is there a gerrit/Jenkins trigger that'll help me automate this more exactly? (Currently we have a main build job per major component... but I might only need one global job that triggers for any merged component to handle the final disposition of said artifacts.)


Jenkins has a trigger for "change abandoned" too.

There's no problem having more than one Jenkins job per branch/change/commit/push, both with fire (and will return a combined comment on Gerrit so there's no extra email spam).

You can create a new global jobs that will just trigger on merge or abandoned (just add both triggers). Your build or post-build action can be a shell script or utility program that will do what you want.