Add a new Push Rule for Jira Commit Acceptance
Description
Our workflow requires that commits (in this case, pushes) are checked against the state of Jira tickets and denied if no ticket can be found that can be used to justify the commit.
Proposal
We propose a Push Rule that checks the commit log message against Jira with the following requirements:
- The Push rule shall provide several verifications that each of them can be enabled or disabled in the GitLab project settings
- The Push rule shall require the following common parameters which shall be configurable in the GitLab project settings ** JIRA server URL ** JIRA user name ** password of JIRA user ** regular expression that matches a JIRA key *The common parameters of the Push rule shall be configurable globally in administration settings, and in the GitLab project settings ** if parameters are not available in the project settings, the parameters from the global settings are used ** if parameters are available in the project settings, the parameters from the project settings are used
- The Push rule shall contact the JIRA server given by the configured URL and login with configured user credentials
- The Push rule shall retrieve issues from the JIRA server and get values from issue fields
- The Push rule shall use the JIRA REST API
- The first verification of the Push rule shall check if for each JIRA key present in the commit message an issue exists on the JIRA server, using the configured regular expression to extract JIRA key(s) from the commit message
- The first verification of the Push rule shall fail and deny the push if any of the referenced JIRA issue(s) does not exist
- The second verification of the Push rule shall check if the assignee of each JIRA issue referenced in the commit message is identical to the author of the push; the comparison is based on the user name or on the email address
- The second verification of the Push rule shall fail and deny the push if the assignee of any referenced JIRA issue(s) is different from the author of the push
- The third verification of the Push rule shall check if the status of each JIRA issue referenced in the commit message is present in configurable list of allowed status.
- The third verification of the Push rule shall require the following parameters which shall be configurable in the GitLab project settings ** list of allowed JIRA issue states
- The third verification of the Push rule shall fail and deny the push if the status of any referenced JIRA issue(s) is not contained in the list of allowed states
Links / references
Documentation blurb
To enable Commit Acceptance functionality, this rule can be used to check a ticket with a Jira ID mentioned in a commit message against a set of rules.
Commit acceptance is used in a scenario with fairly rigid change controls, where every change has to be discussed by a change control board. Change controls such as this are used e.g. in highly safety critical environments.
The most common use is to check if the ticket exists, is in the correct state (e.g. "Approved for implementation") and is assigned to the person attempting the push.