Often we come across scenarios where we need to add a new link in JIRA under various places in the user interface. The first thing that comes to mind is "Oh I need to modify the jsps and that means my upgrades are going to be a nightmare"! But hang on, JIRA is far better than you think! Adding a link is JIRA can be achieved pretty easily by writing a web-section and/or web-item plugin module. And that doesn't involve writing any programming languages, including JAVA. A Web item is a new link that can be added into various places in the JIRA UI. A link will typically go under a web section. A link can simply point to a URL or can be used to invoke an action. Whatever the link is, we can add them in to JIRA in few steps. Firstly, Identify the web section where the new link should be added. We can create our own web sections using a web-section plugin module or identify an existing section in JIRA. How about creating a new one? We first need to identify a location in JIRA where the new web section will be added. A list of JIRA locations can be found at Atlassian Web Fragment documentation. Let us say, we are going to add it under the system administration screen. The web section module is added into atlassian-plugin.xml as follows: <web-section key="jtricks-admin-section" name="JTricks Section" location="system.admin" i18n-name-key="webfragments.admin.jtricks.section" weight="900"> <label>J Tricks</label> <description>J Tricks Section Descitption</description> <tooltip>J Tricks - Little JIRA Tricks</tooltip> </web-section> Here we define the location as system.admin and that puts the section under system administration page. We also have given a useful label, description and a tooltip. A link is then added into a section created as above or into a pre-defined JIRA section. We can directly add the link to a location if it is a non-sectioned one. For sectioned locations, it is the location key, followed by a slash ('/'), and the name of the web section in which it should appear. For example, if we want to place a link in the web section created before, the section element will have value system.admin/jtricks-admin-section. <web-item key="jtricks-admin-link" name="JTricks Link" section="system.admin/jtricks-admin-section" i18n-name-key="webfragments.admin.jtricks.item" weight="10"> <label>J Tricks Website</label> <link linkId="jtricks.admin.link">http://www.j-tricks.com</link> </web-item> A Web item module has a unique key. The other two important attributes of a web-item are section and weight. Section defines the web section where the link is placed as mentioned above and weight defines the order in which the link will appear. A web item also has all the elements of a web section - condition/conditions, context-provider, description, param, resource and toolitp, details of which can be found here. In addition a web item also has a link element that defines where the web item should link to. The link could be an action, a direct link etc and can be created dynamically using velocity parameters as shown in the examples below: <link linkId="create_link" absolute="false">/secure/CreateIssue!default.jspa</link> <link linkId="google_link">http://www.google.com</link> <link linkId="profile_link" absolute="false">/secure/ViewProfile.jspa?name=$user.name</link> An icon element is used when we need to add an icon alongside the link. <icon height="16" width="16"> <link>/images/avatar.gif</link> </icon> All that is pending is to bundle the plugin descriptor into a plugin jar and deploy it. Once deployed, we can see that a new web item is created in the Web section we have created previously under the Admin screen of JIRA. We can add the item under various different places just by changing the section attribute. So little to do for such a big use case!
29 Comments
mohammed italy
6/8/2011 09:42:52 pm
thank you for this page , i made my jira link and this link drive you to a form i made in jira . i want to know the code to put in my plugin to get data from this form , i already wrote in my class request.getParameter ("param") to get data but now i don't know the code to write in myform.vm to send this data to another vm file
Reply
J-Tricks
6/8/2011 09:49:42 pm
You should write a webwork plugin instead of writing a standard JSP form to make things easier. You will find more details about webwork in JIRA at http://confluence.atlassian.com/display/JIRA/JIRA+Webwork+Actions.
Reply
mohammed italy
6/9/2011 04:48:15 am
thank you for your answer .
Reply
J-Tricks
6/9/2011 06:57:22 am
Mohammed, JIRA 3.13 will also support jsps. Having said that, you can use velocity templates also with webwork1. The way the action classes and action forwarding works is same!
Reply
xu jin
6/9/2011 08:21:59 pm
hello, i also have 3.13 and i want o create a jira plugin from eclipse not with sdk in DOS , i already download maven2 plugin in my eclipse. now i can create a maven plugin in my eclipse the problem is that : when i do "run as maven package" maven made my jar but when i do "run as maven install " he installs the jar but not in the directory WEB-INF/lib of jira but in other directory , so i must copy the jar and paste it in my WEB-INF/lib of jira .
Reply
mohammed italy
6/10/2011 04:52:56 am
thank you so much i found the plugin that you linked me so helpful , i hope to not come back with another question again ... i want only to know if there is some code to know how the make a search in jira mail issues , and thank you again you are so helpful
Reply
J-Tricks
6/10/2011 07:37:09 am
@Mohammed Glad we could help. Check out http://confluence.atlassian.com/display/JIRA041/Updating+JIRA+Plugins+for+JIRA+4.0#UpdatingJIRAPluginsforJIRA4.0-NewSearching to know about searching!
Reply
Med
6/14/2011 09:40:24 pm
hi i have this error in my plygin :
Reply
J-Tricks
6/15/2011 04:08:31 am
Hello Med,
Reply
Med
6/15/2011 10:49:12 am
should i put it under atlassian-jira/template of jira directory in my case C:\JIRA-Enterprise-3.13.1\atlassian-jira\template ?? if yes , i have other subdirectories there , can i put them there wherever? and the last question should i call them as i did with .vm files ?
Reply
J-Tricks
6/15/2011 07:19:02 pm
Med,
Reply
alcantar
6/19/2011 09:03:35 pm
hi there,
Reply
J-Tricks
6/20/2011 09:12:42 pm
@alcantar searching can be done using JqlQueryBuilder as described at http://confluence.atlassian.com/display/JIRA041/Updating+JIRA+Plugins+for+JIRA+4.0#UpdatingJIRAPluginsforJIRA4.0-NewSearching. You just need to use the appropriate JQL. Hope it helps.
Reply
Chris
7/27/2011 10:49:39 pm
Perfect, exactly what I was looking for.
Reply
11/22/2011 08:58:26 am
Hi there, I was wondering if it was possible to change an interface item. We'd like to modify the way watching appears on the issue screen. for example, instead of seeing Watchers (0), we would like to see something like:
Reply
J-Tricks
11/22/2011 11:30:34 am
@Joe You can modify the templates/jira/issue/block/peopleblock.vm file residing under WEB-INF/classes and add the description alongside the link!
Reply
11/22/2011 01:45:48 pm
Hmm - I'm not able to find that file under there. In fact, I do not even see a "block" folder under the issue folder?
Reply
11/22/2011 01:54:10 pm
Hey there,
Reply
J-Tricks
11/22/2011 03:54:15 pm
Oh, you are on JIRA 4.4? In JIRA 4.4, they have it as a separate plugin. It is in the jira-view-issue-plugin-4.4.3.jar!
Reply
11/22/2011 03:59:43 pm
Hi! Thanks for getting back to me so quickly.
Reply
Joe Caputo
11/22/2011 04:22:43 pm
I love this site. Best resource for jira plugin development bar none.
Reply
J-Tricks
11/23/2011 12:14:52 am
@Joe That's right. Unzip, make changes in jar, zip it ;)
Reply
Uldis
5/17/2012 10:39:29 pm
Hello, Jobin.
Reply
J-Tricks
5/18/2012 01:23:35 am
Yes, you can do it with the help of conditions as mentioned here: https://developer.atlassian.com/display/PLUGINFRAMEWORK/Web+Item+Plugin+Module
Reply
Uldis
5/20/2012 09:32:36 pm
wow, thanks. I think I will start with global permissions, because our customers does not have some global permissions that our employees do and then see wether I need to actually write my own condition.
Nandhini
3/16/2015 11:51:30 pm
Iam new to JIRA SDK,I am trying to create tab named req , in which it consists of two sub tabs searchreq and createreq, now i have to display two different page(vm files) in two different sub tabs, please find below my code...
Reply
J-Tricks
3/21/2015 03:43:26 am
/secure/JTricksDemoAction!in.jspa will look for a method doIn() in the action class.
Reply
Yagnesh
6/30/2016 05:43:37 pm
I am facing some issues in web item creation here : https://answers.atlassian.com/questions/39238874/web-item-doesnt-work-as-expected-in-jira-7.1.8
Reply
Your comment will be posted after it is approved.
Leave a Reply. |
AuthorJobin Kuruvilla - Works in Adaptavist as Head of DevOps Professional Services. Categories
All
Archives
October 2016
|