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 a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781782169086
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Apr 25, 2013
Length: 512 pages
Edition : 1st
Language : English
ISBN-13 : 9781782169086
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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.