These scripts are to be used with Atlassian Bitbucket Server to restrict commits by the contents of the commit logs.
Bitbucket Server as of version 5.0.1 only supports pre-receive
and
post-receive
hooks via its web UI. Neither of those git hooks has
access to the commit log messages. Only the update
hook can
process it.
update
The git update hook
validate-issue.js
A node.js commit log validation script.
It checks commit log format, JIRA issue assignee, and JIRA issue status.
Requires 'jsmin' module to be installed.
validate-issue.conf
A configuration template file for the validate-issue.js script.
The file format is JSON (with comments) and the contents are self-documented.
This file must reside in the same directory with the validate-issue.js script.
This project assumes that you have the following components installed on your server:
- Atlassian Bitbucket Server version 5.0.1 or newer (although should work for older versions as well)
- node.js framework with
node
executable. On Linux that requires installation ofnodejs-legacy
package. On Windows it is sufficient to install the generic node.js package from http://nodejs.org - Atlassian JIRA (may reside on another host, but should be accessible via network)
It is also recommended to have a special service account enabled in JIRA. The account should have a read-only access to all projects. Use that account in validate-issue.conf.
The scripts must be installed in the repository's directory inside Bitbucket Server:
- Go to Bitbucket home, e.g. on Windows that may be
C:\Atlassian\ApplicationData\Bitbucket
- Go to
shared/data/repositories
and identify which of the numbered directories there contain your repository. You can usegit log
inside those directories to do that. - Go to the hooks dir of your repository's directory, e.g.
13/hooks
- Put the files of this project listed above into that directory
- Run
npm install jsmin
to install thejsmin
module required for validate-issue.js - Edit validate-issue.conf to reflect your network and account configuration
In order for these hooks to be installed automatically for each new repository,
take the same steps as for single repository installation, but put instead of steps 2 and 3,
go directly to the hook templates directory shared/config/git/templates/hooks
.