
Enforce the JIRA issue id in a GIT commit message
This can be done by using git hooks file location at .git/hooks/commit-msg. Following are the 2 way in whcih each Developers can set the Hooks in their developement envioronment.
Method โ 1
[code]# commit-msg.sh
#!/bin/sh
# This hook will make sure that the commit message contains a JIRA issue.
#
# To enable this hook, rename this file to โ.git/hooks/commit-msgโ.
# Make sure to add execution permissions to the file.
export MESSAGE=$(<$1)
export JIRA_ISSUE_TAG=โISSUETAG-([0-9]*)โ
if [[ $MESSAGE =~ $JIRA_ISSUE_TAG ]]; then
echo -e โ\e[32mGreat, your commit message contains a JIRA issue!\e[0mโ
exit 0;
fi
echo -e โ\e[31mOh hamburgers โฆ You forgot to add a JIRA issue number!\e[0mโ;
exit 1;
[/code]
Method 2 โ This is another very good example to implement to force jira id in each commit message. http://nsbogan.com/tools/2015/06/04/jira-id-in-git-commit-messages






Iโm a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND