JIRA integration & other external project links
By Steve on February 6, 2012SourceTree 1.3 makes it easy to navigate to JIRA issues which are associated with your commits – and in fact to other supporting information like Crucible reviews or any predictable pattern in a commit message that you can identify.
Linking a repository to a JIRA project
If you’re committing code to resolve a JIRA issue, you’ll normally include the JIRA issue number in the commit message, perhaps something like this:
PROJECTX-101 Fixed bad encoding on UTF-16 characters
Wouldn’t it be awesome if when you looked at that commit message in the log, that ‘PROJECTX-101’ was a link to the JIRA issue? Well, it turns out that’s really easy in 1.3.
Simply click the ‘Settings’ button on the repository toolbar, select the Advanced tab, and look for the ‘Commit Text Replacements’ section:
Here you can see one I prepared earlier. To create it, I clicked ‘Add’ and entered these details:
All I needed to do was specify the project prefix (every JIRA project has one of these), and supply the base URL for my JIRA installation. With this in place, SourceTree will search for all instances of ‘PROJECTX-<number>’ in commit messages, and will hyperlink it to the issue itself, like this:
Clicking that link would open the issue at https://jira.myproject.com/browse/PROJECTX-101 in your default web browser.
Advanced usage – other types of links
It’s not only JIRA issues which can be linked. If you change the ‘Replacement Type’ box you can see there’s anther helper option for Crucible projects (which works much the same way as JIRA), but there is also an ‘Other’ option, which allows you to specify your own text replacements in terms of regular expressions. They could be links to other tracking systems, or indeed any other kind of replacement. Here’s an example:
You can specify a regular expression pattern to search for in the commit message, and what text should replace it. You can use capture clauses (parenthesis in the regex pattern, variable names in the ‘Replace With’ field) in order to extract details and reformat them. The keen-eyed among you may have noticed that the screenshot above actually represents the same JIRA link replacement, just in raw regex form – notice how it is looking for the issue pattern, and then replacing it with HTML to form a link. So you can do anything you need to do to translate commit plain text into HTML of your choosing.
We hope you enjoy this SourceTree 1.3 feature!
15 Comments
Would love to see built-in links for GitHub. But at least there is a custom option. Will definitely take a look at this.
Now if I only could set a default here… I have a ton of repositories using the same issue tracker, and setting up a custom replacement for each individually is a pain…
In my case we have over 2000 repositories in the company, as you can imagine configuring this for each of them is a nonsense.
This is already done automatically from the DCVS linking from JIRA when using Bitbucket, would presume it works for Stash as well, then all issue keys are rendered as links to JIRA in bitbucket and and links to the change set in Bitbucket in JIRA.
Perhaps I have a different workflow from most people, but I’ve used Microsoft source control tools and I don’t think that in a source control environment like this one, no one should ever ever ever ever ever ever have to manually look up the JIRA issue number they’re associating their commit with. You already have users log in, you already allow users to create issue filters in JIRA, you have a great REST API for querying issues, etc. I would be very nice to simply be able to pick an issue from a list, select what to do with is (log work, resolve, etc.) write a commit comment and be done with it. I’m sorry for the rant, but I really love Atlassian products, and I don’t understand why this feature doesn’t exist anywhere including your IDE connectors.
Yep, this is definitely on our radar for the next few months.
So on the Radar for the next few months? is it done yet?
Would be great if this capability existed.
The current feature is very brittle since you can mistype the issue id and it provides a pretty link to nowhere. You also still have to go to the ticketing system to change the status if there is a change.
There are frankly, lots of desktop git tools. And I think this is probably the best one. But what doesn’t exist today, is a really good desktop (non-IDE) git tool that can send commit info to a ticketing system and trigger ticketing system actions at the same time.
What I would love to see is when I’m doing a sourcetree commit, to be able to press button to pick the issue ID, and then after picking the issue ID, being able to pick a status change (if any) when you do the commit. So that I could then have my git commit comment annotated with the ticketing system reference, and my ticketing system comment annotated with the git commit info.
And if you guys want to not seem to tightly tied to JIRA (though I think that is a good feature), you could have some plugin architecture where a plugin provides the integration to the ticketing system. But I would hope you guys would include a rock solid plugin to JIRA 🙂
I’m guessing by “on your radar”, you mean .. you’re seeing it fly into view and then past, FAR FAR AWAY. Wish this feature was actually on your “will do” list instead.
2 points:
* This blog relates to SourceTree for Mac 1.3 (current SourceTree for Windows version is 0.9.4)
* This feature isn’t available in SoureTree for Windows …. (at least I havv’t found it yet)
Yes, when this blog was written a year ago, SourceTree was at 1.3 and was only available for the Mac. The Windows version has only been out for a couple of months and is still catching up with many features, but we do intend to bring it up to speed in the next few months.
As of this writing it’s available in windows. Top right > Settings > Advanced > Commit Text Links in version 1.3.
Finally with today update Windows has the feature. A little bit better documentation for Commit text link details is needed though…
For some reason regular expressions don’t work for me in SourceTree 1.8.3.0 on Windows. I tried even the simplest example: replace (.*) with word ‘test’ and it didn’t replace anything. Under Mac OS it works fine.
Could you please open a ticket at support.atlassian.com and include screenshots or a video? Thank you.