James Roper

So, you've slayed the Atlassian integration dragon. But you're still edgy, it was too easy! You want something harder. Well I have just the task for you. Actioning JIRA issues from Subversion commit messages. Before I go on, let me say, this task is not part of the official Atlassian Dragon Quest. You will not get another free tshirt if you complete this task. But, you will get one cool integration feature from Atlassian's products.

Actioning issues from commit messages is a feature that has been available in JIRA Studio for around a year. The documentation on how to use it (once it's set up) can be found here. This feature was, from the start, written as a feature that could be used outside JIRA Studio. However, there was a small amount of effort required to get it to that point. That effort has never been done, until now. Well, some of it has been done. It's still only recommended to be tried by only the bravest of dragon slayers.

First, a bit about how actioning issues with commit commands work. Atlassian has a little known cross product plugin called the Atlassian Notifier. This plugin implements WebHooks for Atlassian products. Using a REST interface, other servers can subscribe to notifications of events on the Atlassian product. In our case, a servlet in the JIRA FishEye plugin will subscribe to commit notifications from FishEye, this servlet will parse the commit messages, and action JIRA issues accordingly.

Requirements

In order to complete this task, you will need:

  • To have completed the Atlassian Dragon Quest
  • Version 3.1-beta2 of the JIRA FishEye plugin, available here
  • A patch for the built in JIRA workflow
  • The FishEye Atlassian Notifier plugin version 2.1-beta1, available here
  • A Subversion repository that you can commit to (can be a local filesystem repository)
  • The Firefox Poster plugin

Setup

  1. Install the JIRA FishEye plugin 3.1-beta1 into the plugins/installed-plugins directory in the JIRA home directory
  2. From the atlassian-jira directory, apply the workflow patch, using the command patch -p0 < jira-workflow.xml.patch
  3. Restart JIRA
  4. Install the FishEye Atlassian Notifier Plugin into the var/plugins/user directory in FishEye
  5. Restart FishEye
  6. Add your Subversion repository to FishEye.
  7. Grant the "charlie" user you created administrator access to FishEye. This can be done by clicking the Administrators link in the FishEye administration menu.
  8. In Firefox, log in to FishEye with the charlie user. Now, using the Firefox Poster plugin, send a POST request to {your fisheye base url}/plugins/servlet/notifier/{your repository}/COMMIT, with content type application/x-www-form-urlencoded, and the content url={your jira base url}/plugins/servlet/commitnotification&authenticationType=TRUSTED_APPS&username=charlie. The response code should be 201 Created.

You're now ready to go.

Testing

  1. Create an issue in JIRA
  2. Check out your source code. If using a file system SVN repository, make sure you specify the --username charlie option.
  3. Make a change, and then commit, with a commit message of {ISSUEKEY} #resolve It works

Within a couple of minutes, your issue should be resolved, and a comment "It works" added to the issue.

If these instructions don't work for you (remember, this task was not for the faint hearted!), then please leave your feedback as comments on this post.

11 Comment(s)

Nice! A few questions.

1. Step 8, what's that for? Enabling something in FishEye it looks like.

2. What about custom workflows, how to add their details? Is the #resolve based on the transition name in JIRA (case-insensitive) or something else?

And in general, how does this handle rebuilding a FishEye index? Does FishEye resend all the notifications so that JIRA will suddenly have a frenzy of trying to action issues that have already been actioned.

~Matt

By Matt Doar at October 9, 2009 11:40 AM

1. Step 8 is setting up the subscription from FishEye to JIRA of commits. It tells FishEye, everytime there's a commit, to post the details to JIRA at that URL. This functionality is provided by the Atlassian Notifer plugin, and can be used as a generic webhook to post commits to anything. The authenticationType can also be BASIC, in which case it will use HTTP BASIC authentication, and you need to supply a password parameter as well. You can also specify NONE for authentication.

2. There is an administration screen for configuring commit commands: http://confluence.atlassian.com/display/JIRASTUDIO/Configuring+Commit+Commands+for+Issues The instructions there apply to the JIRA Studio administration layout, but the commit commands link can be found in the Global Settings section of the administration menu. The commands are actually stored as properties on the workflow, this is why the patch is needed, because JIRA doesn't allow editing the built in workflow.

I'll have to check, but I don't think rebuilding the index will cause notifications to be resent. The worst it will do is cause notifications to be missed. The commit event publishing mechanism stores the ID of the last revision it published in the index itself, and only publishes revisions since that index. If the it doesn't find that stored ID, which would happen when you first point FishEye at a repository or if you rebuild the index, it doesn't publish anything, it just stores, and this only happens after the entire index has finished rebuilding. So, when you rebuild the index, any commits that happen while its being rebuilt may not be published. There is still a chance of JIRA being hammered, if FishEye goes down for a long time, and then is brought back up, and lots of commits have happened in the mean time.

If you do try this, would appreciate any feedback you have. It is likely that at some point we'll add subscribing to commit notifications a button on the administration screen for the JIRA FishEye plugin. Getting this to a state usable outside of JIRA Studio was just something that I decided to do last Friday as part of my 20% time, because I thought it was about time we offered it to customers (many have asked about it).

By James Roper at October 10, 2009 5:23 AM

Thank you very much for the solution.

We still had to add the two paths
   /plugins/servlet/streams
   /plugins/servlet/commitnotification
to the
   URL Paths to Allow:
list in the FishEye trusted application configuration in JIRA

By Andreas Würl at October 12, 2009 4:23 AM

Thanks for the walk through. I've got both beta plugins installed and the POST returned a 201, but I can't download the xml.patch file because the SVN repo is requesting a username and password.

So I'm stuck with a blank "Commit Notification Command Mappings" page in JIRA Administration.

Interestingly enough, the page lists the table header (Command|Transitions|Action) and an 'Add workflow command mapping' link.

A workaround others might be interested in. I've copied the default jira workflow, created a new workflow scheme, and assigned a workflow to each issue type of the new workflow scheme. Finally, for each project, I needed to change the workflow scheme from None to Copied Workflow.

By Brad at December 8, 2009 1:46 PM

Hi Brad,

The commit notification command mappings page I think had a bug in it (overlooked by me in my race to get something done on a Friday afternoon). This has since been fixed and beta 2 has been released:

http://maven.atlassian.com/contrib/com/atlassian/jira/plugins/jira-fisheye-plugin/3.1-beta2/jira-fisheye-plugin-3.1-beta2.jar

Let me know if this fixes it.

That SVN repository has recently been made private, I've copied the patch to this website:

http://blogs.atlassian.com/developer/commitnotifications/jira-workflow.xml.patch

I hope this works for you!

By James Roper at December 8, 2009 3:57 PM

I wasnt able to get it to this to work with standalone installs of Fisheye and JIRA. I can see Fisheye sending the notification to JIRA and JIRA responsding with a status 200. Since I havent followed the Dragon Quest procedure maybe it is a problem with authentication since im not using Crowd?

By Thomas Brosnan at December 18, 2009 11:12 AM

Thomas,

Can you check the following things:

* You have trusted apps setup so JIRA trusts FishEye
* The username you used in step 8 when you posted the subscription to FishEye is a system administrator on JIRA
* The usernames that are doing the commits in Subversion exist on JIRA, and have permission to perform the actions you're trying to perform.

By James Roper at December 20, 2009 3:10 PM

This is make or break for us with Jira Standalone. Absolutely have to have action issues with commit commands and we're not interested in Studio. We must be able to include keywords in our commits that will not only cause workflow transitions but also add comments to the issue (to generate emails to watchers) - the lack of this in the Standalone version might be enough to prevent us from migrating from Trac.

Still, I thought I'd give this Fisheye integration a try, but here's where I'm stuck and hope you can help. I've proceeded with all of the steps and am still coming up with 'FishEye - 403 Forbidden' on the Firefox Poster Post even though the username I provide is an admin on both the Fisheye and jira installations. I also added the paths mentioned by Andreas above to Jira's Trusted Applications / Fisheye entry.

'You do not have permission to access that resource. Only an administrator can manage subscriptions'

running release
FE2.1.2
(build-444 2009-11-18)

By Tom Lichtenberg at January 13, 2010 9:00 AM

We are trying this but hitting a 500 server error. In the fisheye log we see the following (note that I have edited out our repository name):

ERROR - /plugins/servlet/notifier/***/COMMIT
java.lang.NullPointerException
at com.atlassian.notifier.core.NotificationManagerImpl.validateSubscription(NotificationManagerImpl.java:184)
at com.atlassian.notifier.core.NotificationManagerImpl.addSubscription(NotificationManagerImpl.java:164)
at com.atlassian.notifier.core.servlet.NotificationSubscriptionServlet.doPost(NotificationSubscriptionServlet
.java:105)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
etc.

By Evan at January 27, 2010 5:34 PM

Hi Evan,

Error reporting could definitely be improved here, this NullPointerException indicates that no callback URL was set in the request. Could you double check that you've set the content type appropriately (to application/x-www-form-urlencoded) and that the message body that you're sending includes the url parameter (eg, url=http://localhost/jira/plugins/servlet/commitnotification).

Cheers,

James

By James Roper at January 31, 2010 2:36 PM

James, that was it - the content type had a typo. Thank you!!

By Evan at February 1, 2010 6:20 PM

Post a comment

If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.





Remember personal info?

Type the characters you see in the picture above.