Applicable: | Jira 7.0.0 and later. |
Level of experience: | Advanced. You should have completed at least one intermediate tutorial before working through this tutorial. See the list of tutorials in DAC. |
Time estimate: | It should take you approximately 1 hour to complete this tutorial. |
In this tutorial, you'll learn how to use a web panel plugin module to add a custom tab to Jira Software boards. While the web panels module is common to Atlassian products, this module will extend a Jira Software-specific location in the interface.
The tutorial is intended to show you how to make a customization to Jira Software, but also to walk you through the development flow for developing a Jira Software app with the Atlassian Plugin SDK.
Our app will add a tab in the Jira Software UI similar to the existing ones, such as Details and People tab. Notice that each tab has a heading, icon link on the left, and tab content. We'll need to create them in our app as well.
About these instructions
You can use any supported combination of operating system and IDE to create this app. These instructions were written using IntelliJ IDEA 2017.3 on macOS Sierra. If you use another operating system or IDE combination, you should use the equivalent operations for your specific environment.
This tutorial was last tested with Jira 7.7.1 using Atlassian Plugin SDK 6.3.10.
To get the most out of this tutorial, you should know the following:
We encourage you to work through this tutorial. If you want to skip ahead or check your work when you are finished, you can find the app source code on Atlassian Bitbucket.
To clone the repository, run the following command:
1 2git clone https://bitbucket.org/atlassian_tutorial/adding-an-issue-view-tab-in-jira-agile.git
Alternatively, you can download the source as a ZIP archive.
In this step, you will create your app skeleton using the Atlassian Plugin SDK.
Set up the Atlassian Plugin SDK and build a project if you did not do that yet.
Open a Terminal and navigate to the directory where you would like to keep your project.
To create an app skeleton, run the following command:
1 2atlas-create-jira-plugin
To identify your app, enter the following information when prompted.
group-id |
|
artifact-id |
|
version |
|
package |
|
Confirm your entries when prompted.
The SDK generates the project home directory with project files, such as the POM (that is, Project Object Model definition file), stub source code, and app resources.
Navigate to the directory created in the previous step.
Delete the test directories.
Setting up testing for your app isn't part of this tutorial. To delete the generated test skeleton, run the following commands:
1 2rm -rf ./src/test/java rm -rf ./src/test/resources/
Delete the unneeded Java class files.
1 2rm -rf ./src/main/java/com/example/plugins/tutorial/jiraagile/*
Import project in your favorite IDE.
It's a good idea to familiarize yourself with the project configuration file, known as the POM. The POM defines general settings for the project, including project dependencies and build settings.
The SDK generates and maintains the POM on its own, for the most part. However, you need to manually tweak some of the included metadata for your project.
Navigate to the project directory created by the SDK and open the pom.xml
file.
Add your company or organization name and your website URL as the name
and url
values of
the organization
element:
1 2<organization> <name>Example Company</name> <url>http://www.example.com/</url> </organization>
Update the description
element:
1 2<description>Adds a view tab to JIRA Software boards.</description>
Save the file.
In this step, you will use the plugin module generator (that is, another atlas
command) to generate the stub
code for modules required by the app.
For this tutorial, you will need a Web Panel plugin module. You'll add this using the
atlas-create-jira-plugin-module
command.
In a Terminal window, navigate to the app root folder where the pom.xml
is located.
Run the following command:
1 2atlas-create-jira-plugin-module
Select the Web Panel
option.
Enter the following information when prompted.
Plugin Module Name |
|
Location |
|
Select Y
for Show Advanced Setup.
Accept the defaults for:
Select Y
for Add resource.
To configure the resource, enter the following when prompted.
Resource Name |
|
Resource Type | velocity |
Location |
|
Select N
for Add a resource parameter.
Select Y
for Add another resource.
Enter the following parameters for the resource when prompted.
Resource Name |
|
Resource Type | download |
Location |
|
Select N
for Add a resource parameter.
Select N
for Add another resource.
Select Y
for Add a Velocity context parameter.
Accept the default for the fully qualified context provider class that should be something like this:
com.example.plugins.tutorial.jiraagile.web.contextproviders.MyContextProvider
Select N
for Add Conditions prompt.
Select N
for Add another plugin module.
The SDK generates the module artifacts, indicating the new items in the output.
The SDK got you started with your web panel module, but it left you a few things to do.
Navigate to src/main/resources/
and open the atlassian-plugin.xml
file.
Add a few more child elements to the web-panel that you just added:
1 2<label key="gh.issue.panel.reference" /> <tooltip key="gh.issue.panel.reference.tooltip" />
src/main/resource/images
directory.This will be the icon for the tab in the issue view.
Note that any icons that you create for your own custom tabs should be of a similar size, about 14 × 14 pixels.
In this step, you will create the Velocity template that produces custom view tab content.
Navigate to src/main/resources
and create a directory
folder.
In the new directory
folder, create a file named reference-gh-issue-details-panel-1.vm
.
Add the following content to the file:
1 2<div class="ghx-container"> <h4>Einstein Quotes</h4> <blockquote> The secret to creativity is knowing how to hide your sources. </blockquote> <blockquote> Imagination is more important than knowledge. Knowledge is limited. </blockquote> <blockquote> I am enough of an artist to draw freely upon my imagination. </blockquote> <blockquote> When I examine myself and my methods of thought, I come to the conclusion that the gift of fantasy has meant more to me than any talent for abstract, positive thinking. </blockquote> <blockquote> The true sign of intelligence is not knowledge but imagination. </blockquote> <blockquote> To raise new questions, new possibilities, to regard old problems from a new angle, requires creative imagination and marks real advance in science. </blockquote> <blockquote> True art is characterized by an irresistible urge in the creative artist. </blockquote> <blockquote> The monotony and solitude of a quiet life stimulates the creative mind. </blockquote> <blockquote> It is the supreme art of the teacher to awaken joy in creative expression and knowledge. </blockquote> </div>
In the same resources directory, open the properties file called MyViewTab.properties
.
Add the following properties:
1 2gh.issue.panel.reference=Reference Issue Tab Panel gh.issue.panel.reference.tooltip=Reference Issue Tab Panel Tooltip
This text will appear in the UI as the heading text for your tab and the hover text for the icon.
If you remember, the web-panel
module you added to the app descriptor specified a context-provider
class.
You need to create this class in your project. The class enables the Velocity template to interject its HTML into the
Jira application context.
For more information about context-providers
for web panels, see the
Web Panel plugin module documentation.
Navigate to the root directory of your project and create a file named MyContextProvider.java
.
Add the following content to the file:
1 2package com.example.plugins.tutorial.jiraagile.web.contextproviders; import java.util.Map; import com.atlassian.jira.util.collect.MapBuilder; import com.atlassian.plugin.PluginParseException; import com.atlassian.plugin.web.ContextProvider; public class MyContextProvider implements ContextProvider { private Long itemCount = 4L; @Override public void init(Map<String, String> params) throws PluginParseException { if (params.containsKey("itemCount")) { this.itemCount = Long.parseLong(params.get("itemCount")); } } @Override public Map<String, Object> getContextMap(Map context) { return MapBuilder.<String, Object>newBuilder() .add("atl.gh.issue.details.tab.count", itemCount).toMap(); } }
Notice that this class:
ContextProvider
interface. init()
and getContextMap()
methods. The methods can access and add to the context map,
which are the context variables available for use in our Velocity templates.atl.gh.issue.details.tab.count
to the number on the
tab indicator itself.Save and close the file.
In this step, you will start Jira Software and test the app.
Ensure that AMPS is configured to run with Jira Software. If you haven't done this before, see the Configure AMPS to run Jira with additional applications installed page.
Make sure you have saved all your code changes to this point.
In a Terminal window, navigate to the app root folder where the pom.xml
file is located.
Run the following command:
1 2atlas-run
Jira takes a few minutes to start, Terminal output will notify you of a successful build.
In a browser window, go to Jira home page. The URL is indicated in the Terminal output, such as localhost:2990/jira.
Log in using the default admin/admin credentials.
Select a Scrum software development project as the new project to create. Jira Software prompts you to create a project upon first login.
Go to the board for the project that you created.
Confirm that the Einstein Quotes app appears on the right side of the page, as shown on the image.
Congratulations, that's it!
Have a treat!
As a next step, try adding another tab to your app. Notice that your context provider class is already built for adding multiple tabs, so you need to add another Velocity template, icon file, and web-panel module to the app descriptor.
Rate this page: