In the Part1 of this blog series, you implemented game mechanics for JIRA and tested it using API Terminal. In this part you will install Atlassian SDK and create a JIRA plugin for capturing events raised from JIRA.

Installation

1. Install Eclipse IDE for Java EE Developers

2. Install the Atlassian SDK for Windowsor Linux/Mac.

In this blog, the steps are described for execution on a Windows machine.

Tips:


1. You will build and deploy a JIRA plugin on a local JIRA server. In the process, around 3.5 GB of files (JIRA WAR files and dependencies) will be downloaded. This can take a while, so be patient 🙂 .

2. If you are developing behind a corporate firewall, you need to connect to the Internet through an HTTP proxy. Configuring HTTP proxy for Atlassian SDK is described here (refer to “Configure a <proxy> in the Maven settings.xml).



Deployment of JIRA plugin


A sample JIRA plugin that listens to events like issue created and issue resolved has been attached. You will need to download and deploy this plugin to your local JIRA server.

1. Download the file jira-gamification-plugin.zip and extract its contents. The extracted contents should  look like this:

jira-gamfication -plugin.png

2. Open a command prompt. Change directory to the folder where the contents of the zip file were extracted to.

3. Run the following command:

atlas-run                                

4. Once JIRA has started successfully, open the URL printed in the message.

JIRAStarted.png

5. Log in with following username and password.

Username: admin

Password:  admin


6. A dialog will explain the product in a series of steps. Click the Next button for each step, until you reach the step “Your first project” like shown below.

Provide Project name and Key as Test and TEST.

FirstProject.png


7. Create an issue by clicking on ‘Create action as shown in the screenshot below.

create Issue.png

8. Enter details for the new issue as shown below in the Create Issue Dialog and click on Create.EnterDetailsForIssue.png

9. Switch to the command prompt where you started JIRA server. You should see a message logged like shown below:

AdminHasCreatedIssue.png

You may open the log file and search for the string “has created issue” in case you cannot find the message in the command prompt.The log file with all the messages logged by JIRA server can be found at the following location in the jira-gamification-plugin folder:

\target\jira\home\log\atlassian-jira.log

10. Stop the JIRA server by typing Ctrl+C in the command prompt.

Congratulations!! You have successfully extended JIRA to capture an event from JIRA.

Now let’s see how this was achieved. Open the file IssueCreatedResolvedListner.java and locate the method onIssueEvent(). This method is called by JIRA to report events, such as when an issue is created.

60 @EventListener

61         public void onIssueEvent(IssueEvent issueEvent) {

62                     Long eventTypeId = issueEvent.getEventTypeId();

63                     Issue issue = issueEvent.getIssue();

64                     UserProfile remoteUser = manager.getRemoteUser();

65                     String username = remoteUser.getUsername();

66                     if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {

67                                 log.info(username+” has created issue {} at {}.”, issue.getKey(),

68                                                         issue.getCreated());                             

69                     }

70     }

You can read more about event listeners for JIRA, how they are registered and the parameters in JIRA documentation.

In this step, the events are just logged. In the next blog, this code will be enhanced to send issue created event to SAP HANA Cloud Platform gamification service.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Gregory Tutt

    Hey mate,

    Do you have any experience/code to make this plugin work on JIRA On-Demand ? (so not on a local JIRA but on the cloud version)

    Regards

    Greg

    (0) 

Leave a Reply