SourceTree

JIRA integration & other external project links

By on February 6, 2012

SourceTree 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.

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

  • Posted February 6, 2012 at 12:17 pm | Permalink

    Would love to see built-in links for GitHub. But at least there is a custom option. Will definitely take a look at this.

  • Karsten
    Posted February 16, 2012 at 7:08 pm | Permalink

    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…

    • Sorin Ionuț Sbârnea
      Posted October 30, 2012 at 10:16 am | Permalink

      In my case we have over 2000 repositories in the company, as you can imagine configuring this for each of them is a nonsense.

  • Magnus Klingenberg
    Posted November 6, 2012 at 1:07 am | Permalink

    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.

  • Andrei
    Posted May 17, 2013 at 11:45 am | Permalink

    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.

    • Anonymous
      Posted May 20, 2013 at 1:52 am | Permalink

      Yep, this is definitely on our radar for the next few months.

      • Posted May 6, 2015 at 5:13 am | Permalink

        So on the Radar for the next few months? is it done yet?

      • D Fly
        Posted June 19, 2015 at 1:57 pm | Permalink

        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 🙂

      • Posted July 21, 2016 at 9:12 am | Permalink

        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.

  • hoppfrosch
    Posted June 3, 2013 at 2:17 am | Permalink

    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)

    • Anonymous
      Posted June 3, 2013 at 7:56 am | Permalink

      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.

      • Anonymous
        Posted October 29, 2013 at 8:13 am | Permalink

        As of this writing it’s available in windows. Top right > Settings > Advanced > Commit Text Links in version 1.3.

  • Slava UA
    Posted October 25, 2013 at 12:28 am | Permalink

    Finally with today update Windows has the feature. A little bit better documentation for Commit text link details is needed though…

  • Artem MIkhailov
    Posted April 8, 2016 at 11:42 am | Permalink

    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.

    • Rahul Chhabria
      Posted April 8, 2016 at 12:26 pm | Permalink

      Could you please open a ticket at support.atlassian.com and include screenshots or a video? Thank you.