|
Writing a JIRA 3 plugin
[
vmassol
]
On one of my projects at work we have moved to JIRA 3 (beta). We moved to benefit from the new custom workflow feature. Unfortunately it was missing one key feature we wanted: the ability to send notification emails on custom workflow transitions (I've just been told by Atlassian that this is a feature they're currently working on). To remedy this and thanks to Atlassian's support, I've decided to delve in the JIRA Java API and develop a workflow function plugin to implement email sending. I have to say that JIRA 3's extensibility is great! JIRA can almost be seen as a full fledge foundation for developing project tracking applications, in the same spirit as Eclipse is a full fledge foundation for developing java applications (RCP). Both Eclipse and JIRA come with a default application using this API to demonstrate their power (the IDE for Eclipse, the issue tracker for JIRA). Note that the new plugin system in JIRA has several similiarities with the Eclipse plugin architecture. Of course, I'm sure JIRA still has a lot of ground to cover to expose a plugin API covering all domains of issue tracking (i.e. allowing to replace all parts of the JIRA issue tracker) but it's going in the right direction. Here is a short tutorial on how to develop a workflow function plugin. Note that you should also check the Atlassian tutorial on how to develop plugins. The source code is available here and the plugin jar is available here. Setting up the projectHere's the directory structure I have chosen for my plugin. Please also note that I have used Maven to perform the build (extremely easy to setup as Atlassian is also using Maven and they have all their jars in a Maven remote repository on http://repository.atlassian.com).
A plugin is composed of several files (it is packaged as a JAR at runtime):
The maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/mavenThe [...]
Generating the plugin jar is as simple as typing The Worflow Function plugin extension pointHere's what the
What you have to understand:
The Java APIThe Plugin Factory classWithout further ado, here's the skeleton for the
Those 4 methods are called by JIRA itself:
Here's a look at the
As you can see, the variables The Plugin Function classHere's the code that implements the plugin feature (in our case the sending of the notification email):
The The parameters have the following meanings:
Deploying and executing the pluginDeployment is a simple as dropping the plugin jar in In the following image we can see how JIRA has automatically discovered our plugin and extracted information from the plugin descriptor to make them available at the right extension point in JIRA:
Here is the page (using the
Here is how our function is displayed (using the
I hope you got a good feel of what's possible to do with the JIRA API. Note: For those wondering, I am not affiliated with Atlassian at all. I simply happen to like their tools (JIRA, Confluence) and I like the spirit of their team. Very interesting tutorial, simply explained and easy to understand :-) --Sumati, October 11, 2004 05:01 PM
Nice and direct tutorial. --Ruben, November 3, 2004 08:12 PM
Thanks - excellent getting started tutorial. Jira rocks. --Elliot Metsger, November 20, 2004 04:37 PM
Thanks, your tutorial is really helpful. --Paolo , October 25, 2005 09:43 AM
Hi!, i'm working on a project, is it possible to create in the road map a cascading select to group the issue by kind for a specified version ? thank you a lot olivier.decan@isep.fr --decan, February 6, 2006 02:12 PM
The code in SendmailFunction is not working since Jira 3.2 - see this link: http://confluence.atlassian.com/pages/viewpage.action;jsessionid=HCANIIBAFHGC?pageId=116700 You have to get the issue object this way: --TothJozsef, February 10, 2006 07:25 AM
I've updated the plugin to work with JIRA v. 3.5 and posted it to Atlassian's JIRA space: http://confluence.atlassian.com/display/JIRAEXT/Send+notification+mail+on+transitions --Matt Kenigson, March 16, 2006 07:37 PM
first i would like to say you thanks for this tutoriel. --ben cheikh, November 23, 2006 05:02 PM
It would be great to get this work in 3.6-7. Maven and eclipse are quite new to me. Jira is a great tool! I'm learning about plugins. If you have update to 3.6 or 3.7, It would be great. --Ville, February 5, 2007 03:25 PM
Great tut! I'd like to know if any of you found a way to add a Test Case Management plugin into JIRA, we are looking for a tool that can easily communicate with our issue tracking tool (JIRA) so, it would be really great if such a tool would exist (JIRA plugin at best). I already looked for GreenPepper's product and that's not what we need. Thx! --Jordan, February 19, 2007 03:43 PM
Hello, i would like to know if we are obliged to redefine all the methods of AbstractWorkflowPluginFactory's abstract class(i.e getVelocityParamsForInput, getVelocityParamsForView,getDescriptorParams,...) even if we don't need any input parameters for our plugin ? Thanks --Lem, February 5, 2008 09:56 PM
You wrote in 2004 "(I've just been told by Atlassian that this is a feature they're currently working on). " Its now 2008? Has this feature been implemented in the out of the box JIRA or do we still need this plugin? --mike, March 1, 2008 12:30 AM
Awesome tutorial - even now some 4 yrs after its been written. What would be helpful would be some kind of update wrt using Maven 2 - I've a couple of queries regarding the correct dir structure. But an idiot-proof (no comments pls !) step-by-step guide would be great ( > really thats directed at Atlassian in case they're reading ;-) ) cheers ! btw yes mike email sending is active out of the box.. --Richard, June 17, 2008 04:12 PM
I'm using version of Jira 3.13.2 and when I create post function "Send Notification Mail" I get this error message after execution transition. Error message: Details: --Robert, April 6, 2009 04:25 PM
Can you help my somebody with this error? I use version of JIra 3.13.2. with metioned plugin.
Details: --Robert, April 7, 2009 09:46 AM
Post a comment
|