Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Need assistance to write a custom listener?

Warren McInnes
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2014

Hi all/Jamie,

I need assistance with a custom listener, based on (https://answers.atlassian.com/questions/292619/move-issues-assignee-automatically-project-lead-only-please-assist?page=1#292652)

1. I have create a permission scheme that allows users in role (Operational Support) to be allowed to move issues between projects, but not assign permission. These tasks need to be assigned to the project lead automatically.

2. I need a listener that will recognise a user in role (Operational Support) when moving a task between projects. During the moved the assignee needs to become the project lead.

Once the project lead has recieved the issue, this person has the permission to assign it the the correct person based on the priority on the issue.

Can anyone assist me?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

Hi Warren,

I would suggest you write a custom listener that listens for Issue Moved events. From the IssueEvent class you can get all information about the project and the user who initiated the event. Make use of the ProjectRoleManager (https://docs.atlassian.com/jira/6.2.1/com/atlassian/jira/security/roles/ProjectRoleManager.html) to check if the user who initiated the event has the Operational Support role. If so you can get the project lead user object from the current project and set this as a assignee for the project.

Feel free to ask more questions :) Hope this gets you started?!

Warren McInnes
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

Hi Benji,

I have never written a custom listener before, I will require assistance from start to finish? Can you help?

Where should I start and what knowledge is requred?

Thanks

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

Hi Warren,

In this case I would suggest you start here:

https://developer.atlassian.com/display/JIRADEV/Writing+JIRA+Event+Listeners+with+the+atlassian-event+Library

This tutorial learns you how to write a custom plugin that registers a listener to receive issue events. The programming language used here is Java, but the basics for other languages (f.e Groovy) is the same.

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

Once the previous tutorial was completed you will have access to an IssueEvent object:

https://docs.atlassian.com/jira/6.2.3/com/atlassian/jira/event/issue/IssueEvent.html

From this class you can retreive info about the event:

- User that started the event

- Issue project

- Issue itself

-...

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

The next step is to check that the user who initiated the event has the group Operational support and this is done via the GroupManager:

https://docs.atlassian.com/jira/6.2.1/com/atlassian/jira/security/groups/GroupManager.html

The method getUsersInGroup returns all users that are part of a certain group. To check wether the user from the IssueEvent is in this list of users. Then you know that he also has the group Operational Support.

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

Your listener has to keep some state, because an issue move event from one project to another consists of 2 event:

1) Project 1 will throw a move event

2) Project 2 will throw a create event

https://confluence.atlassian.com/display/JIRA/Moving+an+Issue

You have to check that when you retrieve a create event in project 2 that a move event was also fired in project 1 for the same issue. Otherwise the create event was not caused by an issue move.

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

The last step is to update the issue assignee and this is done with the IssueService:

https://developer.atlassian.com/display/JIRADEV/Performing+Issue+Operations#PerformingIssueOperations-EditinganexistingIssue

The IssueInputParameter you need to set is setAssigneeId.

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

When the create event for project 2 was fired you can retrieve the project from the IssueEvent class and next retrieve the project lead user object from the Project class:

https://docs.atlassian.com/jira/6.2.1/com/atlassian/jira/project/Project.html

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

In order to use your plugin you have to upload it to your JIRA instance:

https://confluence.atlassian.com/display/UPM/Installing+add-ons

Hope this gets you on track?!

Warren McInnes
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

Thanks, I'll make a start and then comment back if i get stuck.

BenjiI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2014

Ok, I'll check for updates :)

TAGS
AUG Leaders

Atlassian Community Events