Search code examples
githubjiragithooksgithub-enterprise

Create git pre-receive hook to link git commits with jira id


I am trying to create a pre-receive hook in github enterprise. I want to put a check on commit message, that it should contain a jira id (say 'RP-123') along with some text. And that commit shoould be visible in jira as a link to github.

Can someone please help me with this. Thanks!

I have integrated jira with github by adding it to OAuth Apps under developer settings. I tried to add an executable script under /git/hooks folder to verify commit message, but this is going to do only client side verification since .git folder is not version controlled in github. Can you please let me know how to add server side verification for commit message and how jira will be linked to those specific commits


Solution

  • If I’m not too late, you can do this using pre-receive hook. An example of pre-receive hook using regex is here: https://github.com/github/platform-samples/blob/master/pre-receive-hooks/require-jira-issue.sh