Book Image

JIRA 5.x Development Cookbook

Book Image

JIRA 5.x 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. "JIRA 5.x Development Cookbook" is a one stop resource to master extensions and customizations in JIRA. 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. "JIRA 5.x Development Cookbook" 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, and so on, and a lot of planning done for the project, 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. "JIRA 5.x Development Cookbook" steers towards programming issues, such as creating, editing, and deleting issues, creating new issue operations, managing the various other operations available on issues via the JIRA APIs, and so on. In the latter half of "JIRA 5.x Development Cookbook", 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 5.x Development Cookbook
Credits
About the Author
Acknowledgement
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 our plugin development easier, Atlassian provides the Atlassian plugin software development kit (SDK). It comes along with Maven and a preconfigured settings.xml file to make things easier.

The 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

Following are the prerequisites for running the Atlassian plugin SDK:

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

  • JDK should be installed and Java version 1.6.x is required.

    Note

    The SDK is not yet compatible with Java 1.7.

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

How to do it…

Following are the steps to set up our development environment:

  1. Once we have installed Java and the port 2990 is ready, we can download the latest version of Atlassian plugin SDK from https://developer.atlassian.com/display/DOCS/Getting+Started.

  2. Install the SDK by following the instructions provided on the Atlassian Developer Documentation page, depending upon the operating system. Let's call this directory SDK_HOME.

  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/atlassian-plugin-sdk directory.

    Note

    SDK version 4.x and above doesn't need this step.

  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 file under M2_HOME/conf/ by modifying the localRepository attribute to point to the embedded repository folder. By default, it will use the USER_HOME/.m2/repository directory.

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

With the preceding steps executed properly, we have a development environment for JIRA plugins. The next step is to create a skeleton plugin, import it in to your IDE, and start writing some code! Creating the skeleton plugin, deploying it, and so on, is explained in detail in the forthcoming recipes of this chapter. So, ready, set, go…

There's more…

If you are facing issues while downloading the dependencies using Maven, just read on.

Proxy settings for Maven

If you are executing behind a firewall, make sure you have configured proxy settings in Maven's settings.xml file. A 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>

Note

To find out more about proxy settings for Maven and other aspects of it, go to 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 the M2_HOME environment variable to your local Maven, and update the respective settings.xml file with the repository details in the default settings.xml file that ships with the Atlassian plugin SDK. Or, you can simply add the following lines to the existing settings.xml file:

<pluginRepository>
  <id>atlassian-plugin-sdk</id>
  <url>file://${env.ATLAS_HOME}/repository</url>
  <releases>
    <enabled>true</enabled>
    <checksumPolicy>warn</checksumPolicy>
  </releases>
  <snapshots>
    <enabled>false</enabled>
  </snapshots>
</pluginRepository>

Configuring IDEs to use the SDK

If you are using IntelliJ IDEA, configuring it to use the SDK is an easy job because IDEA integrates Maven out of the box. Just load the project by selecting the pom.xml file! See https://developer.atlassian.com/display/DOCS/Configure+IDEA+to+use+the+SDK for more details.

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 https://developer.atlassian.com/display/DOCS/Set+Up+the+Eclipse+IDE+for+Linux for Linux, or https://developer.atlassian.com/display/DOCS/Set+Up+the+Eclipse+IDE+for+Windows for Windows.

If you are using Netbeans, check out https://developer.atlassian.com/display/DOCS/Configure+NetBeans+to+use+the+SDK on how to configure it to use the SDK.

Troubleshooting

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

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

  • Proxy configuration is done if required.

  • Antivirus in the local machine is disabled and/or firewall restrictions removed if none of the above works! Seriously, it makes a difference.

See also

  • The Creating a skeleton plugin recipe