1

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.

Antonow297296
  • 317
  • 1
  • 4
  • 12

2 Answers2

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
Community
  • 1
  • 1
uncletall
  • 6,609
  • 1
  • 27
  • 52
  • @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.