How does an admin configure Gerrit to automatically reject commits without JiRA ticket number? I've read this documentation but not sure how to implement it on all branches in a specific repository (not all repos!). Do all users need to download the file and copy it to their local repository or how does it work? What I want to achieve is that git/gerrit automatically rejects a commit that are missing a JiRA ticket number - doesn't have to be valid, it's up to the team to control that the ticket number is valid.
Asked
Active
Viewed 531 times
2 Answers
3
The Jira plugin is based in the ITS plugin. These plugins have a association configuration that can be set to MANDATORY.
MANDATORY : One or more issue-ids are required in the git commit message, otherwise the git push will be rejected.
SUGGESTED : Whenever git commit message does not contain one or more issue-ids, a warning message is displayed as a suggestion on the client.
OPTIONAL : Issues-ids are liked when found on git commit message, no warning are displayed otherwise.
The below config example is taken from the Jira plugin documentation.
[commentLink "Jira"]
match = (\\[[A-Z][A-Z]+-[1-9][0-9]*\\])
html = "<a href=\"http://myjira.com/browse/$1\">$1</a>"
association = MANDATORY
-
@Antonow297296 the JIRA plugin can be disabled/enabled by project, hence it should cover your use case (i.e.: "in a specific repository (not all repos!)"). – barbasa Nov 28 '19 at 20:08
1
The Git::Hooks is the best solution to this job.
See how to install and configure it here.
See more info about it here.

Marcelo Ávila de Oliveira
- 19,950
- 3
- 39
- 50