Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
JIRA 5.x Development Cookbook
JIRA 5.x Development Cookbook

JIRA 5.x Development Cookbook: This book is your one-stop resource for mastering JIRA extensions and customizations

eBook
€8.99 €39.99
Paperback
€48.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

JIRA 5.x Development Cookbook

Chapter 2. Understanding the Plugin Framework

In this chapter, we will cover more details on the JIRA architecture and the plugin framework. We will also cover the following recipes:

  • Modifying Atlassian bundled plugins

  • Converting plugins from v1 to v2

  • Adding resources into plugins

  • Adding web resources into plugins

  • Building JIRA from source

  • Adding new webwork actions to JIRA

  • Extending a webwork action in JIRA

  • Capturing plugin installation/uninstallation events

Introduction


As we saw in the previous chapter, the JIRA plugin development process is probably an easier task than we expected it to be. With the help of Atlassian Plugin SDK, developers can spend more time worrying about the plugin logic than on the troublesome deployment activities. And yes, after all, it is the plugin logic that is going to make an impact!

This chapter details how the various components fit into JIRA's architecture and how JIRA exposes the various pluggable points. We will also look at an overview of JIRA's system plugins to find out how JIRA uses the plugin architecture to its own benefit, followed by some useful recipes.

JIRA architecture

We will quickly see how the various components within JIRA fit in to form the JIRA we know. It is best described in a diagram, and Atlassian has a neat one along with a detailed explanation at https://developer.atlassian.com/display/JIRADEV/JIRA+Architectural+Overview. We will redraw the diagram a little bit to explain it in a brief...

Architecture explained


It is best to learn the intricacies of system architecture with the help of a diagram. For the benefit of a brief but meaningful explanation on the JIRA architecture, let us have a quick look (or a long stare, whichever you are more comfortable with!) at the following diagram:

JIRA is a web application built using the MVC architecture. It is fully written in Java and is deployed as a WAR file into a Java Servlet Container such as Tomcat.

The majority of the JIRA core functionality revolves around the JIRA Utility and Manager Classes, which thus becomes the heart of JIRA. It also interacts with a lot of third-party components, which we saw earlier, to deliver powerful functionalities such as workflows, permissions, user management, and searching.

As with any other web application, let us start with the incoming requests. Users interact with JIRA using web browsers, but there are other ways to interact with JIRA, such as using the Jelly scripts or by making remote calls...

Types of plugin modules


Let us briefly see the different types of plugin modules supported in JIRA5. All these modules are various extension points, using which we can not only add new functionalities in to JIRA, but also extend some of the existing functionalities.

Let us group them based on functionality instead of seeing them all together!

Reporting

Module type

Description

Gadget

Adds new Gadgets into the user's dashboard. These gadgets can also be accessed from other applications.

Report

Adds new reports in to JIRA.

Workflows

Module type

Description

workflow-condition

Adds new workflow conditions to the JIRA workflow. It can then be used to limit the workflow actions to users, based on pre-defined conditions.

workflow-validator

Adds new workflow validations to the JIRA workflow. Validations can be used to prevent certain workflow actions when certain criteria are not met.

workflow-function

Adds new workflow post functions to the JIRA workflow. These can be used to...

Working with the Plugins1 and Plugins2 versions


Let us also quickly see how to deal with the Plugins1 and Plugins2 versions.

Before we go on to the details, it is essential to understand the importance of both these versions. Pre 4.x, JIRA used to support only the Plugins1 version. So why do we need the Plugins2 version?

The key motive behind version2 plugins is to keep the plugins as a bundle isolated from the other plugins and the JIRA core classes. It makes use of the OSGi platform (http://www.osgi.org/) to achieve this. While it keeps the plugins isolated, it also gives you a way to define dependencies between plugins, leaving it to the plugin developer's convenience. It even lets you import or export selected packages within the plugin giving increased flexibility.

The fact that the version2 plugins are deployed as OSGi bundles also means that the plugins are dynamic in nature. They may be installed, started, updated, stopped, and uninstalled at any time during the running of the framework...

JIRA system plugins


In this section, we will see a brief overview of the JIRA system plugins.

A lot of JIRA's functionality is written in the form of plugins. This not only showcases what we can achieve using plugins, but also helps us, as developers, to understand how the various pieces fit together.

If it is the atlassian-plugin.xml file that describes the plugin functionalities, JIRA maintains the information in *.xml files placed under WEB-INF/classes. You will also find the related classes in the exploded folders under WEB-INF/classes.

Let us have a quick look at the various system plugin XMLs that can be found in WEB-INF/classes and the functionality they support:

System plugin XML

Functionality

system-contentlinkresolvers-plugin.xml

System content link resolvers: Resolves parsed content links into link objects.

  • Attachment link resolver

  • Anchor link resolver

  • JIRA issue link resolver

  • User profile link resolver

system-customfieldtypes-plugin.xml

JIRA system custom fields: All the...

Stable and core APIs


So, we are in to coding. If you are familiar with JIRA plugin development or have been using them prior to JIRA 5, one thing you might have noticed is that there are quite a few versions of every plugin out there! There are not many plugin versions that work on all JIRA versions. You might also know the reason behind this: JIRA has been evolving a lot in terms of its APIs.

With JIRA 5, Atlassian has introduced stable and core APIs, and with great interest, the development community read the following blog written by Rich Manalang: http://blogs.atlassian.com/2012/03/stable-apis-yes-we-have-them/

The earlier atlassian-jira dependency, which was used in JIRA plugins prior to JIRA 5, is now replaced by two different dependencies: jira-api and jira-core. jira-api (aka the stable API) is a set of classes or interfaces that will not be changed without prior notice. Atlassian will maintain binary compatibility for these classes and interfaces.

jira-core, on the other hand,...

Modifying Atlassian bundled plugins


As we discussed earlier, more and more standard functionalities are pushed into bundled plugins as opposed to the JIRA core product. There is no better way to showcase the plugin architecture, I must admit! But that does make the life of high end users who want to modify those functionalities a bit difficult.

Let me take a once simple scenario such as "I want to display the description before the issue details in the View Issue page."

This used to be pretty easy, because all you needed to do was to modify the relevant JSP file and that's it! But now, the View Issue screen rendering is done by jira-view-issue-plugin and it is an Atlassian system plugin. Although the actual work is simple—we only need to modify the atlassian-plugin.xml file—making those changes effective is not as simple as editing the jira-view-issue-plugin-xxx.jar file from the JIRA_Home/.plugins/bundled-plugins folder.

Let us see why!

How to do it…

The reason is pretty simple. All the system...

Converting plugins from v1 to v2


If you are moving to JIRA 4.x+ from JIRA 3.13.x or earlier versions, one of the important differences is the introduction of v2 plugins. While designing the upgrade to JIRA 4.x+, it makes perfect sense to sometimes migrate the plugins from v1 to v2, although it is not a mandatory step. In this recipe, we will see how to convert a version1 plugin to a version2 plugin.

Getting ready

There are a couple of questions we need to ask before the plugin is converted:

  • Are all the packages used by the plugin available to OSGi plugins?

    This is very important because JIRA doesn't expose all the packages to OSGi plugins.

    Note

    The list of packages exported and made available to the Plugins2 version can be found in the com.atlassian.jira.plugin.DefaultPackageScannerConfiguration class.

  • Are all the components used by the plugin available to OSGi plugins?

    Similar to the previous question, we need to make sure the components are also exposed to the OSGi plugins.

    Note

    Unfortunately,...

Adding resources into plugins


It is often required to add static resources such as JavaScript files, CSS files, and so on in to our plugins. To enable JIRA to serve these additional static files, they should be defined as downloadable resources.

Getting ready

A resource can be of different types. It is normally defined as a non-Java file that the plugin requires to operate.

Examples of resources that you will come across during JIRA plugin development include, but are not restricted to, the following:

  • Velocity (*.vm) files required to render a view

  • JavaScript files

  • CSS files

  • Property files for localization

How to do it…

To include a resource, add the resource module to the atlassian-plugin.xml file. The resource module can be added as part of the entire plugin or can be included within another module, restricting it just for that module.

The following are the attributes and elements available for the resource module and their uses:

Name

Description

name

The name of the resource. This is used...

Adding web resources into plugins


The web resources plugin module, like the resource module we just saw, allows for the defining of downloadable resources. The difference is that the web resources are added at the top of the page in the header with the cache-related headers set to never expire.

An additional advantage of using the web resources module is that we can specify the resources to be included in specific contexts within the application.

How to do it…

The root element for the web resource plugin module is web-resource. It supports the following attributes:

Name

Description

key

The only mandatory attribute. This should be unique within the plugin.

state

This indicates whether the plugin module should be disabled by default or not. The default value enabled. value="disabled" will keep the plugin disabled at startup.

i18n-name-key

The localization key for the human-readable name of the plugin module.

name

The human-readable name of the web resource.

system

This indicates...

Building JIRA from source


One of the best things about JIRA, if you have a valid license, is that you get to see the source code. You can see it, modify it, break it… err? In this recipe we will modify it, because you have the license to do it!

Getting ready

Following are some of the prerequisites prior to building JIRA from the source:

  • A valid JIRA license to get access to the source code.

  • An environment with JDK 1.5 or higher for JIRA 4.2 and lower versions. JDK 1.6.x is required for JIRA 4.3 and above versions.

  • You will need both Maven 1 and Maven 2 if you are building versions prior to JIRA 4.3. Download Maven version 1.0.x and 2.1.x from http://maven.apache.org/. JIRA 4.3 and above versions only need Maven 2.1.0.

    Note

    You need both Maven 1 and Maven 2 for versions prior to JIRA 4.3, because Maven 1 is required to build the JIRA source and Maven 2 is required to build plugins for JIRA. JIRA has bundled plugins that need to be built along with JIRA, and so Maven 2 is also a must.

    Maven 2.1.0...

Adding new webwork actions to JIRA


Most of the time, plugin developers will find themselves writing new actions in JIRA to introduce new functionality. Usually these actions are invoked from new web-item links configured at different places in the UI. It could also be from customized JSPs or other parts of the JIRA framework.

New actions can be added to JIRA with the help of the webwork plugin module.

Getting ready

Before we start, it probably makes sense to have a look at the webwork plugin module. Following are the key attributes that are supported:

Name

Description

key

A unique key within the plugin. It will be used as the identifier for the plugin.

class

This will be java.lang.Object as the real logic will reside in the action, Class.

i18n-name-key

The localization key for the human-readable name of the plugin module.

name

The human-readable name of the webwork action.

The following are the key elements supported:

Name

Description

description

The description of the...

Extending a webwork action in JIRA


There are so many user stories for this one! How do you override some of the JIRA built-in actions? How do you do some additional stuff in the JIRA built-in action? Like doing some crazy things immediately after logging work on a ticket, or doing some innovative validations on some of those actions.

Extending the existing JIRA action is an answer to all these questions. Let us see in detail how to do that.

How to do it…

Extending a JIRA action is done with the help of the webwork plugin module. Most of it is very similar to writing new webwork actions.

Let us take the case of the AddProject action. What should we do if we need to extend this action? Say, to do some additional validation during the creation of a project?

Let us consider an example where we want to prevent users from creating project keys using reserved words.

The following are the steps to do this:

  1. Identify the action to be overridden by looking up the actions.xml file under WEB-INF/classes in...

Capturing plugin installation/uninstallation events


We have seen plugins that are great in terms of functionality but come with a big list of configuration steps. Its much like a treadmill; a great asset but very hard to assemble!

Is there a way we can handle these configurations automatically (like creating custom fields, adding options, creating listeners, services, and so on), when the plugin is installed? The answer is "Yes".

How to do it…

It is simple. Really! Let us look at creating a custom field automatically during a plugin installation and deleting it while uninstalling. The same logic applies as for the enabling/disabling of the plugin. All you need to do is two simple steps:

  • Write an event listener. We will use the atlassian-event library here.

  • Implement the Spring interfaces InitializingBean and DisposableBean to capture the plugin lifecycle events.

Writing an event listener in JIRA is quite easy. Just perform the following steps:

  1. Import the EventPublisher instance used to register...

Left arrow icon Right arrow icon

Key benefits

  • Extend and customize JIRA; work with custom fields, workflows, reports, gadgets, JQL functions, plugins, and more
  • Customize the look and feel of your JIRA user interface by adding new tabs, web items and sections, drop down menus, and more
  • Master JQL (JIRA Query Language) that enables advanced searching capabilities through which users can search for issues in their JIRA instance and then exploit all the capabilities of the issue navigator

Description

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.

Who is this book for?

If you are a JIRA developer or project manager who wants to fully exploit the exciting capabilities of JIRA, then this is the perfect book for you.

What you will learn

  • Create and deploy your own JIRA plugins
  • Deal with custom fields on an issue and program custom field options
  • Program and customize workflows to transform JIRA into a user friendly system
  • Put together reports that show statistics for particular people, projects, versions, or other fields within issues
  • Simplify reporting by writing your own JIRA gadgets, which can be added into a user s dashboard
  • Create, edit, and delete issues
  • Master database handling in JIRA --retrieve issue information from the database, extend the database, retrieve custom field details from the database, access database entities from plugins, and more
  • Communicate with JIRA via the REST, SOAP, or XML/RPC interfaces

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 25, 2013
Length: 512 pages
Edition : 1st
Language : English
ISBN-13 : 9781782169093
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Apr 25, 2013
Length: 512 pages
Edition : 1st
Language : English
ISBN-13 : 9781782169093
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 144.97
JIRA 5.2 Essentials
€53.99
Atlassian Confluence 5 Essentials
€41.99
JIRA 5.x Development Cookbook
€48.99
Total 144.97 Stars icon
Banner background image

Table of Contents

11 Chapters
Plugin Development Process Chevron down icon Chevron up icon
Understanding the Plugin Framework Chevron down icon Chevron up icon
Working with Custom Fields Chevron down icon Chevron up icon
Programming Workflows Chevron down icon Chevron up icon
Gadgets and Reporting in JIRA Chevron down icon Chevron up icon
The Power of JIRA Searching Chevron down icon Chevron up icon
Programming Issues Chevron down icon Chevron up icon
Customizing the UI Chevron down icon Chevron up icon
Remote Access to JIRA Chevron down icon Chevron up icon
Dealing with the JIRA Database Chevron down icon Chevron up icon
Useful Recipes Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(4 Ratings)
5 star 75%
4 star 0%
3 star 0%
2 star 25%
1 star 0%
Sim Hua Soon Jun 11, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have read the previous edition of the JIRA Development Cookbook and found it to be an extremely useful reference. I am glad that I have the updated edition by my side.This updated edition of the Cookbook had been updated with changes and new features introduced in JIRA 5.It's really useful for anyone who wants to start coding new features to their JIRAs.
Amazon Verified review Amazon
Amazon Customer May 28, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book on JIRA 5, for all things JIRA, development, plugins, interfacing, business.If you want to make JIRA a key part of your company's infrastructure, than this book is a must.Nice job!
Amazon Verified review Amazon
Dale Miller Jun 19, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have worked with Jira on both the administration side and plugin development. This book is an excellent addition to anyone's library who is working with Jira and is interested in starting plugin development or increasing their knowledge of plugin development. It does a great job of explaining the necessary steps for a beginner to get started and walks you through examples that become more complex as your knowledge grows. It also provides plenty of more in depth information that will fill in the many gaps missing in or difficult to find in Atlassian's online documentation. Examples and instruction are provided for the most often requested extensions to the base Jira tool. This book will definitely be well used on my part.
Amazon Verified review Amazon
chevy Dec 17, 2013
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
The book is probably good for pure developers, but it didn't help me understand the product and to customize it for my purpose.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.