4

Is it possible to customize what is commented in Jira when a commit is pushed in GitHub?

Currently the following information is commented:

  • Triggered by: John Doe
  • Comment: #TST-1234: dummy commit to test jira-github integration
  • Repository: testing
  • Branch: refs/heads/master
  • Git Issue URL: https://github.com/...

And I want it to comment only the URL part, all the rest is not interesting information for me, and I want the comments to be clean.

Genry
  • 1,358
  • 2
  • 23
  • 39

1 Answers1

0

a possible solution could be to customize the commit message itself

ensure that commit messages include the branch name, which in JIRA are most likely derived from the issue title.

To achieve this, coworkers have to include in their .git/hooks directory a file named commit-msg with the following contents :

#!/bin/bash
current_branch="$(git rev-parse --abbrev-ref HEAD)"
tmp=$(mktemp) || exit
echo "$current_branch $(cat "$1")" > "$tmp"
mv "$tmp" "$1"

Then when someone is committing on the feature branch ABC-1234-customers-cant-log-in, a commit command like this :

git commit -m "Awesome changes"

...will actually produce the following commit message :

ABC-1234-customers-cant-log-in Awesome changes

...and JIRA will then link the commit to the issue.

solution and credits goes to answer here: https://stackoverflow.com/a/55008618/7540322

Monem
  • 255
  • 2
  • 15