Dear mates,
i'm looking for a feature in Jira which seems must exist.
In regular everyday workflow every dev have to copy ticket id + summary to put it in the commit message ("AA-1234 Task numer 1").
Can't find such functionality. Copying this data with mouse selection brings a lot of extra data, spaces, line breaks etc which need to clean every time.
Thanks
Hi @ilya this is not a Jira functionality but a git one. There are pre-message hooks and pre-commit hooks that you should look into that can pull the Jira ID off the Branch Name and prepopulate the commit message for you. You can find a lot of examples for this online.
Here's a Bash example for you
#!/bin/bash
# Enable extended globbing patterns, for pulling ticket numbers out of the branch name later
shopt -s extglob
# Get the branch name and try to find a ticket number there
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
# If branch pattern is NOT feature/*, bugfix/*, or hotfix/*, do not apply the Jira Id rule
if [[ ("$BRANCH" != "feature/"*) &&
("$BRANCH" != "bugfix/"*) &&
("$BRANCH" != "hotfix/"*) ]] ; then
exit 0
fi
#Strip off the branch prefix
BRANCH_NAME=${BRANCH#*/}
#Get the after-id tail
TAIL=${BRANCH_NAME#[A-Z][A-Z]?([A-Z])?([A-Z])-+([0-9])-}
if [ "$BRANCH_NAME" != "$TAIL" ]; then
TKT=${BRANCH_NAME%-$TAIL}
fi
FILE_CONTENT="$(cat $1)"
# If we successfully found a ticket number, then amend the comment with the ticket number included
if [ -n "$TKT" ]; then
# Scan the user-provided comment for the given jira ticket number
if grep -v ^# $1 | grep "$TKT" ; then
exit 0
fi
echo Inserting ticket number $TKT from branch name
echo $TKT "$FILE_CONTENT" >$1
exit
fi
# No ticket found anywhere. Abort!
cat >&2 <<EOS
ERROR! COMMIT FAILED
Unable to identify ticket associated with commit!
Commit aborted.
EOS
exit 1
As I understand, the script will parse commit message in real time and predict ticket summary into commit message?
Seems it's not what I'm looking for. Just need a button in Jira ticket to copy "AA-1234 summary" in 1 click, to simplify developers life.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.