Issue Linked Event for JIRA

 

About plugin

Issue Linked Event provide two functionality for JIRA.

Ability to validate linked issues (read Validation strategy in Configuration section)

Fire the custom events when someone created or deleted issue links

Plugin add two custom events into JIRA (Administration – System – View Events). Events will be fired when you create JIRA, Web, Confluence link or when you delete any link from issue.

  • “Issue Link Created” event
  • “Issue Link Deleted” event

You can change template, assciated notification schemes, associated workflows and description, but remember … DON’T CHANGE EVENT NAMES.

If you change it, the plugin will create new events!.

The default setting for new events can be seen below.

 

Download Add-on from Atlassian Marketplace – Issue Linked Event

 

Configuration

Go do -> Add-ons -> Issue Linked Event (Other section in left menu)

  • Call custom Created/Deleted events? – Since v. 1.4.0

You can disable or enable custome events

  • Call event only for current issue? – Since v. 1.3.0

For example if you checked “only for current issue” option and you try add new issue link, event will be fired only for current issue, but if you checked “current and linked issues” option, event will be fired for current and linked issue.

  • Validation strategy – Since v. 1.4.0

You can create rules for linked issues how will they be validated, for example: only Bug can be linked into Task with relation “is blocked by”.

Supported JQL Description Example
sourceLinkFilterX(GLOBAL_LINK_NAME) JQL provide information how to validate outward issues JQL name: sourceLinkFilter1(relates to)
JQL query: issuetyp = Epic and status = “TO DO”Whats that mean?
All issues in outward “Relates” link relation must be a “Epic” in “TO DO” status
destLinkFilterX(GLOBAL_LINK_NAME) JQL provide information how to validate inward issues JQL name: destLinkFilter1(is blocked by)
JQL query: issuetyp = BugWhats that mean?
All issues in inward “Blocks” link relation must be a “Bug”
errorLinkFilterX(GLOBAL_LINK_NAME)

Only for strategy: All validation must by positive

JQL provide information about error messages when validate not pass.

Default error message when valiadation fail or JQL is not set:
You can’t link this issue/issues due to the link restrictions.

JQL name: errorLinkFilter1(Blocks)
JQL query: summary ~ “Example error message for pair 1”Whats that mean?
This is message to show, when validation for first pair not pass.
errorLinkFilter(GLOBAL_LINK_NAME)

Only for strategy: Only one validation must by positive

JQL provide information about error message when validate not pass.

Default error message when valiadation fail or JQL is not set:
You can’t link this issue/issues due to the link restrictions.

JQL name: errorLinkFilter(Blocks)
JQL query: summary ~ “Example error message for only one validation must by positive”Whats that mean?
This is message to show, when validations for linked issues not pass

X – number from 1 to 10
GLOBAL_LINK_NAME – global link name, please see Name on page http://JIRA_URL/secure/admin/ViewLinkTypes!default.jspa

Example:

Event params map

Since v. 1.3.0

Issue Link Created/Deleted events has information about which links have been added or removed.

You can get it using method getParams form class com.atlassian.jira.event.issue.IssueEvent.

Example data in params:

Map<String, Object> params

Add issue/remote link param:

Name: addedIssueLink or addedRemoteLink
Type: ArrayList<Long>
Information: ArraList provide links ids (IssueLink ID or RemoteIssueLink ID)

Removed issue link param:

Name: removedIssueLink
Type: Map<String, String>
Map Keys: 
 - linkTypeId - link type ID
 - sourceIssueId - source Issue ID
 - destinationIssueId - destination Issue ID

Removed remote link param:

Name: removedIssueLink
Type: Map<String, String>
Map Keys: 
 - id - link ID
 - title - link title
 - url - link url

 

How to show it?

I will try to show the plugin in action using script listener and several screenshot from issue actions

Script Listener:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.issue.link.RemoteIssueLinkService;

def eventTypeManager = ComponentAccessor.getEventTypeManager();
def eventType = eventTypeManager.getEventType( event.getEventTypeId() );
def eventTypeName = eventType.getName();
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def issueLinkManager = ComponentAccessor.getIssueLinkManager();
def remoteIssueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService.class);

log.warn (" --- Fire event '"+eventTypeName+"' for issue '"+event.issue.getKey()+"' Params:"+event.getParams().toString() );
//LOG FOR ALL LINKED ISSUES

//GET INFORMATION ABOUT EVENT LINKS
if( eventTypeName == "Issue Link Created" ){
    if( event.getParams()["addedIssueLink"] != null ){
        event.getParams()["addedIssueLink"].each{
            def issueLink = issueLinkManager.getIssueLink(it);
            def linkId = issueLink.getId().toString();
            def sourceId = issueLink.getSourceId().toString();
            def destId = issueLink.getDestinationId().toString();
            //get more -> https://docs.atlassian.com/jira/server/com/atlassian/jira/issue/link/IssueLink.html
            log.warn (" ----- Issue linked ID:$linkId, sourceId:$sourceId destinationId:$destId");
        }
    }else if( event.getParams()["addedRemoteLink"] != null ){
        event.getParams()["addedRemoteLink"].each{
            def remoteLink = remoteIssueLinkService.getRemoteIssueLink(currentUser, it).getRemoteIssueLink();
            def linkId = remoteLink.getId();
            def title = remoteLink.getTitle();
            def url = remoteLink.getUrl();
            //get more -> https://docs.atlassian.com/jira/server/com/atlassian/jira/issue/link/RemoteIssueLink.html
            log.warn (" ----- Issue link ID:$linkId, title:$title, url:$url");
        }
    }
}else{
    if( event.getParams()["removedIssueLink"] != null ){
        def removedLink = event.getParams()["removedIssueLink"];

        log.warn (" ----- Issue link ID:"+removedLink["id"]+" ; linkTypeId:"+removedLink["linkTypeId"]+" ; sourceIssueId:"+removedLink["sourceIssueId"] +" ; destinationIssueId:"+removedLink["destinationIssueId"] );
    }else if( event.getParams()["removedRemoteLink"] != null ){
        def removedLink = event.getParams()["removedRemoteLink"];

        log.warn (" ----- Issue link ID:"+removedLink["id"]+" ; title:"+removedLink["title"]+" ; url:"+removedLink["url"] );
    }
}

and how i set listener in JIRA (using Script Runner)

 

Event – Issue Link Created

Event will be fired when you add new link (JIRA, Web Link or Confluence Link) (Issue -> More -> Link)

   

[INFO] [talledLocalContainer] 2017-08-08 20:10:00,591 http-nio-2990-exec-10 WARN anonymous 1210x846x1 7p2csl 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Created' for issue 'PROJA-1'
[INFO] [talledLocalContainer] 2017-08-08 20:10:00,659 http-nio-2990-exec-10 WARN anonymous 1210x846x1 7p2csl 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Created' for issue 'PROJA-2'
[INFO] [talledLocalContainer] 2017-08-13 10:46:16,499 http-nio-2990-exec-1 WARN admin 646x2186x1 gp42sk 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Created' for issue 'PB-1'

 

Event will be fired when you add Linked Issues on transition screen (every transition with filed Linked Issues)
Event will be fired when you Edit Issue (key ‘e’ or Edit trasition) – Since v. 1.3.0

  

[INFO] [talledLocalContainer] 2017-08-08 20:21:05,455 http-nio-2990-exec-1 WARN admin 1221x1656x1 7p2csl 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Created' for issue 'PROJA-1'
[INFO] [talledLocalContainer] 2017-08-08 20:21:05,489 http-nio-2990-exec-1 WARN admin 1221x1656x1 7p2csl 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Created' for issue 'PROJA-3'

 

Event will be fired when you Create Linked Issue (More -> Create linked issue)
Event will be fired when you Create Issue (Quick create Issue) – Since v. 1.3.0

  

[INFO] [talledLocalContainer] 2017-08-08 20:50:18,492 http-nio-2990-exec-2 WARN anonymous 1250x777x1 1en02ik 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Created' for issue 'PROJA-3'
[INFO] [talledLocalContainer] 2017-08-08 20:50:19,188 http-nio-2990-exec-2 WARN admin 1250x777x1 1en02ik 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Created' for issue 'PROJA-4'

 

Event – Issue Link Deleted

Event will be fired when you delete link

  

[INFO] [talledLocalContainer] 2017-08-08 20:37:46,429 http-nio-2990-exec-9 WARN anonymous 1237x1817x1 7p2csl 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Deleted' for issue 'PROJA-1'
[INFO] [talledLocalContainer] 2017-08-08 20:37:46,469 http-nio-2990-exec-9 WARN anonymous 1237x1817x1 7p2csl 0:0:0:0:0:0:0:1 /secure/*.jspa [c.o.scriptrunner.runner.ScriptRunnerImpl]  --- Fire event 'Issue Link Deleted' for issue 'PROJA-3'

 

 

Support

If you have any questions or suggestions please don’t hesitate to contact me.

Please feel free to contact by support@itlab.net.pl, if you require any further information.