Bennyn
Bennyn

Reputation: 103

git server side 'update' hook in bitbucket

I'm looking for way to create a git server side push hook (will be used to enforce referencing JIRA ticket number in each commit message).

According to pro git - git hooks, the git hook to use on the server side is 'update', which exists on .git/hooks dir. Since I'm using BitBucket for git hosting, I need to somehow send this file to the .git/hooks dir in the site.

Using BitBucket services will not be suitable, since they are 'post-receive' hooks, so there's no point in using existing or writing my own broker, therefore this question doesn't give me a proper solution.

Upvotes: 3

Views: 2631

Answers (3)

Alexander Amelkin
Alexander Amelkin

Reputation: 778

Unfortunately, Bitbucket Server doesn't provide an API or UI to install an update hook. It only supports pre-receive and post-receive hooks on that level. However, since Bitbucket Server uses a generic git at the backend, it is indeed possible to install any of the standard git hooks.

This approach requires filesystem access with admin/root rights to the host where Bitbucket Server is installed.

The hooks are located in shared/config/git/template/hooks and are automatically copied inside per-repository hooks directory when you create a new repository. To install a custom hook for an existing repository, do that in shared/data/repositories/<repo_number>/hooks.

I have created a ready to use solution for validating the commit log against a configurable JIRA host using a configurable username and password. The solution verifies the following:

  • Conformance to Linux kernel style log formatting (50/72 rule)
  • Presence of a JIRA issue key in the summary
  • JIRA issue assignee's e-mail matching the committer's e-mail
  • JIRA issue status being 'In Progress'

You can download the files here: https://github.com/AlexanderAmelkin/bitbucket-git-hooks-for-jira

For portability, the main validation script is written in Javascript for node.js that is available both for Windows and Linux.

Upvotes: 2

Bennyn
Bennyn

Reputation: 103

apparently, it is not possible, according to the answer I got at answers.atlassian.com.

Upvotes: 3

Eugene Ryzhikov
Eugene Ryzhikov

Reputation: 17369

I far I know JIRA now integrates with Bitbucket. All you need is a JIRA Bitbucket plugin

Upvotes: -2

Related Questions