www.it-ebooks.info
JIRA Development
Cookbook
Develop and customize plugins, program workows, work
on custom elds, master JQL functions, and more – to
effectively customize, manage, and extend JIRA
Jobin Kuruvilla
P U B L I S H I N G
professional expertise distilled
BIRMINGHAM - MUMBAI
www.it-ebooks.info
JIRA Development Cookbook
Copyright © 2011 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.
First published: November 2011
Production Reference: 1161111
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK
ISBN 978-1-84968-180-3
Valentina D'Silva
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
www.it-ebooks.info
About the Author
Jobin Kuruvilla is an Atlassian Consultant who is experienced in customizing JIRA and
writing JIRA plugins for various customers. He is working with Go2group, a premier Atlassian
partner and is involved in managing Atlassian products for big enterprises to small starter
license installations.
Jobin had started his career as a Java/J2EE Developer in one of the biggest IT companies
in India. After spending the initial years in the SOA world, he got hooked into this amazing
product called JIRA, which he came across during the evaluation of third-party products for
a requirements management solution. Soon Jobin realized the power of JIRA and pledged to
spread the word. He has been doing it ever since, and reckons there is a long way to go!
Jobin runs a website named "J Tricks – Little JIRA Tricks" (
http://www.j-tricks.com).
He has written numerous tutorials to help the developer community, who he thinks has
contributed immensely to his personal development. It is indeed those tutorials that sowed
the rst seeds for this book.
www.it-ebooks.info
Acknowledgment
No book is the product of just the author – he just happens to be the one with his name on
the cover.
A number of people contributed to the success of this book, and it would take more space
than I have to thank each one individually.
First of all, thanks to the Almighty God for helping me to sail through the difculties in this
short life and for making my life as wonderful as it is now.
The next biggest thanks go to my Acquisition editor, Amey Kanse, who patiently explained to
My deepest gratitude goes to so many people who have trusted me and
supported my efforts. Without them, I couldn't have carried out any of my
projects on JIRA.
I would like to dedicate my work to my wife, Carmen, and my son, Felipe, for
their support and understanding for the many hours I devoted to review this
book.
www.it-ebooks.info
Dawid Kowalski is a third year student at Poznań University of Technology in Poland. He
is currently employed at Wolters Kluwer as a Software Developer and works on JIRA-related
projects. He is ambitious, hard-working, and organized. He is active in the scientic club and
works there on optimization problems. He is also the captain of the Imagine Cup 2010 and
2011 semi-nalist team.
I would like to thank my closest friends and family for continuous support
and encouragement.
Sergey Markovich is currently a co-founder of Plugenta Labs, a company focusing on
the development of add-ons to enterprise software and an independent Atlassian JIRA and
Conuence contractor.
In the past, a code wizard in several multinational corporations and startups and a Bachelor
in Computer Science.
I want to thank my mom and dad for giving me birth and growing me up the
way you did it. Everything I have in my life I it owe to you.
I also want to say warm words to everybody involved with Plugenta Labs. It's
a real pleasure to work with you and I keep learning from you every day.
Marcin Zręda specializes in Business Analysis and Quality Assurance. He has many years
of experience as a programmer and designer. He is the author of many articles on JIRA and
the owner of the http://www.testandtry.com blog. He has implemented JIRA for many
departments for more than 600 employees. He is currently directing the department of
business analysis for a large international company.
My sweet little daughter Anna, the light of my world. I am sure you will read this one
day and understand what I was doing all night scratching my head in front of the laptop
instead of changing your nappies!
My parents, Alice and Kuruvilla, who brought me up in a village
not many people have heard of. Nothing beats the pain and suffering they
have undergone in the process
My sister, Juby Sara, the best sister in the world. It is a privilege watching you
follow my footsteps outshining me all the way!
My friends from TKM and JNV Kottayam who dared me to dream and
then helped me to achieve them. You guys are the best.
This book would not have been possible without your love and understanding.
A big thank you from the bottom of my heart. I have nothing to give back,
but my love and prayers.
www.it-ebooks.info
www.it-ebooks.info
Table of Contents
Preface 1
Chapter 1: Plugin Development Process 7
Introduction 7
Setting up the development environment 10
Creating a skeleton plugin 12
Deploying a plugin 16
Making changes and re-deploying a plugin 19
Testing and debugging 21
Chapter 2: Understanding Plugin Framework 25
Introduction 25
Converting plugins from v1 to v2 41
Adding resources into plugins 43
Adding web resources into plugins 45
Building JIRA from source 47
Permissions based on workow status 118
Internationalization in workow transitions 119
Obtaining available workow actions programmatically 121
Programmatically progressing on workows 123
Obtaining workow history from the database 125
Re-ordering workow actions in JIRA 127
Creating common transitions in workows 129
Jelly escalation 134
Chapter 5: Gadgets and Reporting in JIRA 137
Introduction 137
Writing a JIRA report 138
Reports in Excel format 146
Data validation in JIRA reports 149
Restricting access to reports 151
Object congurable parameters for reports 153
Creating a pie chart in JIRA 160
Writing JIRA 4 gadgets 165
Invoking REST services from gadgets 172
Conguring user preferences in gadgets 176
Accessing gadgets outside of JIRA 184
Chapter 6: The Power of JIRA Searching 189
Introduction 189
Writing a JQL function 190
Sanitizing JQL functions 195
Adding a search request view 198
Smart querying using quick search 204
Searching in plugins 207
www.it-ebooks.info
iii
Table of Contents
Adding new tabs in the View Issue screen 275
Adding new tabs in the Browse Project screen 278
Creating Project Tab Panel using fragments 280
Adding new tabs in the Browse Version screen 285
Adding new tabs in the Browse Component screen 287
Extending a webwork action to add UI elements 289
Displaying dynamic notications/warnings on issues 293
Re-ordering Issue Operations in the View Issue page 296
Re-ordering elds in the View Issue page 298
www.it-ebooks.info
iv
Table of Contents
Chapter 9: Remote Access to JIRA 303
Introduction 304
Creating a SOAP client 304
Creating an issue via SOAP 306
Working with custom elds and SOAP 309
Attachments and SOAP 312
Worklogs and time tracking via SOAP 314
Commenting on an issue via SOAP 316
User and group management via SOAP 317
Progressing an issue in workow using SOAP 319
Managing versions via SOAP 321
Administration methods in SOAP API 322
Deploy a SOAP service in JIRA 326
Deploy a XML-RPC service within JIRA 330
Writing a Java XML-RPC client 333
Expose services and data entities as REST APIs 336
Writing Java client for REST API 342
Chapter 10: Dealing with a Database 345
Using lters to intercept queries in JIRA 408
Adding and importing components in JIRA 411
Adding new module types to JIRA 415
Enabling access logs in JIRA 420
Enabling SQL logging in JIRA 422
Overriding JIRA's default components in plugins 423
Creating issues and comments from e-mail 427
Internationalization in webwork plugins 430
Sharing common libraries across v2 plugins 431
Operations using direct HTML links 433
Index 437
www.it-ebooks.info
www.it-ebooks.info
Preface
This book is your one-stop resource for mastering 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 workows, issues, custom elds, 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 eld plugins to create new eld types or custom
searchers. We then learn how to program and customize workows to transform JIRA
into a user-friendly system.
We will then look at customizing the various searching aspects of JIRA such as JQL, searching
in plugins, managing lters, and so on.
Then the book steers towards programming issues; that is, creating/editing/deleting issues,
creating new issue operations, managing the other various operations available on issues
using the JIRA APIs, and so on.
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 using the REST, SOAP, or XML/RPC interfaces, and
work with the JIRA database.
Chapter 11, Useful Recipes, covers a selected list of useful recipes which do not belong in the
preceding categories, but are powerful enough to get your attention! Read away!!
What you need for this book
This book focuses on JIRA development. You will need the following software as a
bare minimum:
f JIRA 4.x+
f JAVA 1.6+
f Maven 2.x
f Atlassian Plugin SDK
f An IDE of your choice. The examples in the book use Eclipse and SQL Developer.
Some of the recipes are too simple to use the fully-edged plugin development process, and
you will see this highlighted as you read through the book!
www.it-ebooks.info
Preface
3
Who this book is 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.
Conventions
In this book, you will nd a number of styles of text that distinguish between different kinds of
information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "The elds oldvalue and newvalue are populated
using the method getChangelogValue."
A block of code is set as follows:
<! entity to represent a single change to an issue. Always part of a
change group >
<entity entity-name="ChangeItem" table-name="changeitem" package-
name="">
<field name="id" type="numeric"/>
<field name="group" col-name="groupid" type="numeric"/>
If there is a book that you need and would like to see us publish, please send us a note in the
SUGGEST A TITLE form on www.packtpub.com or e-mail [email protected].
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you
to get the most from your purchase.
Downloading the example code for this book
You can download the example code les for all Packt books you have purchased from
your account at http://www.PacktPub.com. If you purchased this book elsewhere, you
can visit http://www.PacktPub.com/support and register to have the les e-mailed
directly to you.
www.it-ebooks.info
Preface
5
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you nd a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you would report this to us. By doing so, you can save other
readers from frustration and help us improve subsequent versions of this book. If you nd
any errata, please report them by visiting http://www.packtpub.com/support,
selecting your book, clicking on the errata submission form link, and entering the details
of your errata. Once your errata are veried, your submission will be accepted and the
errata will be uploaded on our website, or added to any list of existing errata, under the
Errata section of that title. Any existing errata can be viewed by selecting your title from
http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt,
we take the protection of our copyright and licenses very seriously. If you come across any
illegal copies of our works, in any form, on the Internet, please provide us with the location