Book Image

JIRA Development Cookbook - Third Edition

By : Jobin Kuruvilla
Book Image

JIRA Development Cookbook - Third Edition

By: Jobin Kuruvilla

Overview of this book

JIRA provides issue and project tracking for software development teams to improve code quality and the speed of development. With the new version of JIRA, you can create your own JIRA plugins and customize the look and feel of your JIRA UI easier than ever. JIRA Development Cookbook , Third Edition, is a one-stop resource to master extensions and customizations in JIRA. This book starts with recipes about simplifying the plugin development process followed by recipes dedicated to the plugin framework. Then, you will move on to writing custom field plugins to create new field types or custom searchers. You will also learn how to program and customize workflows to transform JIRA into a user-friendly system. With so much data spanning different projects, issues, and so on, we will cover how to work on reports and gadgets to get customized data according to our needs. At the end of the book, you will learn how to customize JIRA by adding new tabs, menus, and web items; communicate with JIRA via the REST APIs; and work with the JIRA database.
Table of Contents (18 chapters)
JIRA Development Cookbook Third Edition
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface

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 preconfigured settings.xml 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 on JIRA.

Getting ready

The following are the prerequisites for running the Atlassian Plugin SDK:

Note

At the time of writing this recipe, the latest version of the Atlassian Plugin SDK is 6.1.0.

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

  • Install JDK. Java version 1.8.X is required for Atlassian Plugin SDK 6.1.0. Please verify the compatible Java version for your SDK version.

  • Make sure the JAVA_HOME is set properly and the command java -version outputs the correct Java version 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://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project.

  2. Unzip the version into a directory of your choice or follow the instructions on the page, depending up on the operating system. Let's call this directory SDK_HOME going forward.

  3. Add the SDK's bin directory into the environment PATH variable. If you are using the installer, this step is automatically done.

  4. Create a new environment variable, M2_HOME, pointing to the apache-maven directory in your SDK Home. SDK version 4.x+ handles this step automatically.

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

  6. Ready, set, go...

There's more...

With the preceding steps executed properly, we have a development environment for JIRA plugins. You can verify the installation of the SDK by running the following command:

atlas-version

This command displays the version and runtime information of the installed SDK.

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.

If you face issues while downloading the dependencies using Maven, read on.

Proxy settings for Maven

If you are behind a firewall, make sure you configure proxy in the Maven settings.xml file. 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 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 the M2_HOME directory to your local Maven and update the respective settings.xml with the repository details in the default settings.xml that ships with the Atlassian Plugin SDK.

Or you can simply add the following to the existing settings.xml:

<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, it is an easy job because IDEA integrates Maven out of the box. Just load the project by selecting the pom.xml! See https://developer.atlassian.com/docs/developer-tools/working-in-an-ide/configure-idea-to-use-the-sdk for 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/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/set-up-the-eclipse-ide-for-linux or https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/set-up-the-eclipse-ide-for-windows, depending on the OS.

For NetBeans, see https://developer.atlassian.com/docs/developer-tools/working-in-an-ide/configure-netbeans-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 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 and/or firewall restrictions removed if none of the above works! Seriously, it makes a difference.