Book Image

JIRA Development Cookbook

Book Image

JIRA Development Cookbook

Overview of this book

JIRA provides issue tracking and project tracking for software development teams to improve code quality and the speed of development.This book is your one-stop resource to master JIRA extension and customization. You will learn how to create your own JIRA plugins, customize the look and feel of your JIRA UI, work with Workflows, Issues, Custom Fields, and much more.The book starts with recipes on simplifying the Plugin development process followed by a complete chapter dedicated to the Plugin Framework to master Plugins in JIRA.Then we will move on to writing custom field plugins to create new field types or custom searchers. We then learn how to program and customize Workflows to transform JIRA into a user-friendly system. Reporting support in an application like JIRA is inevitable! With so much data spanning across different projects, issues, etc and a lot of project planning done on it, we will cover how to work on reports and gadgets to get customized data according to our needs. We will then look at customizing the various searching aspects of JIRA such as JQL, searching in plugins, managing filters, and so on. Then the book steers towards programming Issues, i.e. creating/editing/deleting issues, creating new issue operations, managing the various other operations available on issues via the JIRA APIs etc. In the latter half of the book, you will learn how to customize JIRA by adding new tabs, menus, and web items, communicate with JIRA via the REST, SOAP or XML/RPC interfaces, and work with the JIRA database.The book ends with a chapter on useful and general JIRA recipes.
Table of Contents (19 chapters)
JIRA Development Cookbook
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up the development environment


Now that we know what a plugin is, let 's aim at writing one! The first step in writing a JIRA plugin is to set up your environment, if you haven't done that already. In this recipe, we will see how to set up a local environment.

To make plugin development easier, Atlassian provides the Atlassian Plugin Software Development Kit (SDK). It comes along with Maven and a pre-configured settings.xml to make things easier.

Atlassian Plugin SDK can be used to develop plugins for other Atlassian products, including Confluence, Crowd, and so on, but we are concentrating only on JIRA.

Getting ready

The following are the pre-requisites for running the Atlassian plugin SDK:

  • The default port for the SDK: 2990 should be available. This is important because different ports are reserved for different Atlassian products.

  • JDK Java version 1.5 - 6 must be installed.

  • Make sure JAVA_HOME is set properly and the command java –version outputs the correct Java version details.

  • And of course, JIRA 4.x+ should be installed in your development environment.

    Note

    Make sure you use a context path for your JIRA because there are known issues with the SDK not working when the context path is empty. See https://studio.atlassian.com/browse/AMPS-122 for more details.

How to do it...

  1. Once we have Java installed and the port ready, we can download the latest version of Atlassian Plugin SDK from https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/amps/atlassian-plugin-sdk/.

  2. Unzip the version into a directory of your choice. Let's call this directory SDK_HOME going forward.

  3. Add the SDK's bin directory into the environment PATH variable.

  4. Create a new environment variable M2_HOME pointing to the Apache-Maven directory in your SDK Home.

  5. A lot of commonly used dependencies are already available in the repository folder embedded in the SDK. To use this, edit the settings.xml under M2_HOME/conf/ and modify the localRepository attribute to point to the embedded repository folder. By default, it will use the USER_HOME/.m2/repository.

  6. Install the IDE of your choice. Atlassian recommends Eclipse, IntelliJ IDEA, or NetBeans, as they all support Maven.

  7. Ready, Set, Go…

How it works...

With these steps executed properly, we have a development environment for JIRA plugins.

The next step is to create a Skeleton plugin, import it into your IDE, and start writing some code! Creating the Skeleton plugin, deploying it, and so on, is explained in detail in the following recipes.

There's more...

Even though the aforementioned steps will work in most cases, we will come across scenarios where the setting up of the development environment is not that straightforward. For example, there are extra settings needed for Maven if the machine is behind a firewall. You might even have a local Maven version already installed. In this section, we will see some useful tips on similar cases.

Proxy settings for Maven

If you are behind a firewall, make sure you configure the proxy in the Maven settings.xml file. The proxy can be configured as follows:

<settings>
  .
  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.demo.com</host>
      <port>8080</port>
      <username>demouser</username>
      <password>demopassword</password>
      <nonProxyHosts>localhost|*.demosite.com</nonProxyHosts>
    </proxy>
  </proxies>
  .
</settings>

Find out more about that and other aspects of Maven at http://maven.apache.org/index.html.

Using local Maven

If you are a developer, in many cases you will have Maven already installed in your local machine. In that case, point M2_HOME to your local Maven and update the respective settings.xml with the repository details in the default settings.xml that ships with Atlassian plugin SDK.

Configuring IDEs to use SDK

If you are using IntelliJ IDEA, it is an easy job because IDEA integrated Maven out-of-the-box. Just load the project by selecting the pom.xml!

If you are using Eclipse, make sure you have M2Eclipse installed. This is because Eclipse integrates Maven through the Sonatype M2Eclipse plugin. You can find more details on configuring this at http://confluence.atlassian.com/display/DEVNET/Configuring+Eclipse+to+use+the+SDK.

Troubleshooting

If you see Maven download errors like Could not resolve artifact, make sure you verify the following:

  • Entry in Maven settings.xml is correct. That is, it points to the correct repositories

  • Proxy configuration is done if required

  • Antivirus in the local machine is disabled if none of the above works! Seriously, it makes a difference.

See also

  • Creating a skeleton plugin