When committing with Source Tree is there a way to create a Jira issue by keyword?

There are times when I commit code with Source Tree (or Git) and I mention the JIRA issues in the comments like this (so they get linked with all Atlassian products):

PROJECT-121 Add link to header text
PROJECT-143 Removed border around
PROJECT-303 Something else

But then there are a few other changes that I needed to make that I want to there to be a record for.

So my commit comments usually ends like this:

PROJECT-121 Add link to header text
PROJECT-143 Removed border around
PROJECT-303 Something else
- Added new functionality to form
- Removed text limit on message box
- Found minor typo or incorrect color used in form

So is there a way or a tag I can add to create a new JIRA issue in the comments like this:

PROJECT-121 Add link to header text
PROJECT-143 Removed border around
PROJECT-303 Something else
- Added new functionality to form #createJiraIssue
- Removed text limit on message box #createJiraIssue
- Incorrect color used in form #createJiraIssue

This would be really helpful because then there can be a record for these changes and people can search and raise issues and add comments on these and they would be in the system (if we ever needed them) and I wouldn't have to go through the process of creating them manually. Does this make sense? These are usually minor enough changes but you still want a record for them. We have people that go through and verify commits and resolve and close issues. This would create a record for them that they could also fill out with more information if need be. This type of situation occurs on almost every commit. So it would be a huge benefit to developers wanting to work on and focus on code than logging into Jira to create issues and so on.

4 answers

1 accepted

Hey there,

We do have plans for better integration with JIRA in the future. We have a couple of issues open for this here and here which are worth checking out. Feel free to add comments or create a new issue with further input.

That said, if you want to link the JIRA issue to commits and vice-versa you'd need to use a post-commit hook to get the commit for the issue (if, for example, you wanted to create a comment on the issue with a commit that has been made). Otherwise you can use a pre-commit hook and have a simple script which does a POST request to JIRA containing the details necessary to create an issue based on the commit contents.

You just rename the "pre-commit.sample" file to "pre-commit" (in your .git/hooks folder) and then put whatever you want in it as it runs as a shell script. In your case you'd perhaps want to follow this guide to creating a JIRA issue through a POST request. To get the data out you'll need from the commit I'd highly recommend this article which shows what env vars get set.

Hope that helps

Great! Any solution from Atlassian will be better than my patchwork. Thanks

How would you trace those issues back to the commit? Since the issues still need to be created, there is no JIRA key. Or you would need to install a kind of pre-commit hook that would update the comments. Don't know if that is possible.

That's a good point. You would need a precommit hook that would create the issues and then update the comment like you said. I think Git allows you to update comments after a commit, I'll check. If that isn't possible it would be acceptable (to me) to create a new commit that added issue keys in the next comment. I wasn't at first concerned with adding the keys to comment but now that you mention it it sounds like these issues may get lost without it.

From what I found, and I'm not an expert, is you can change a commit message soon after it's committed but not after others have committed, http://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git, http://stackoverflow.com/questions/457379/how-do-i-edit-an-incorrect-commit-message-in-git-ive-pushed. You can amend a commit message locally before pushing to live. It sounds like it could work.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

21,295 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you