Confluence has been updated to version 6.15.9

JIRA SERVER

This article shows how to use Exalate event listener external script which we've included in the  External scripts library.

Introduction

The script allows subscribing to Exalate Jira issue events:

  • exalated
  • unexalated
  • updated
  • deleted

Use cases

  • Delete original issue once it's synced

This is a common case when you move issues from one instance to another. Once the issue has been synchronized(moved) no need to keep the original issue. 

  • Delete an issue in the target system when it's deleted in the original 

Exalate works such that if you delete an issue that is under sync from the source side, a twin issue remains on the remote side. The twin issue sync status changes to Remote issue removed

With the help of ExalateEventListener.groovy you can remove both: the source issue which is under sync and then the twin issue on the remote side. 

  • Include of Exalate actions under the History tab in Jira

Exalate can notify issue tracker that the event has been synchronized. Based on this notification ExalateEventListener allows to include Exalate actions into history tab.

  • Move issue case: change the source issue status and stop synchronization 

Another common case is when you use Exalate to move issues from one instance to another. Once the source issue is synchronized change its status to Done and stop the synchronization.


Disclaimer

To be able to develop advanced synchronization scripts you require a development background and a good understanding of Groovy and the entities of the underlying issue tracker and Exalate itself. 

In case of need, we can provide training and professional services to deliver the solution you're looking for.  Please contact sales@exalate.com for more information.

Snippet example

Example snippet 1

  1. Check from what instance an issue has been originally synced
  2. If the source instance is X add the issue link "moved to [destination side issue link]"
  3. Change source issue status to done
  4. Stop synchronization on the source side

ExalateEventListener.hangListener(
        connection,
        { String localIssueKey, String remoteIssueKey, localIssue, remoteIssue ->
            // on Exalated
            if (IsSource.isSource(localIssue, connectionId)) {
                IssueLinkSync.addRemoteLink(localIssue, remoteIssueKey, "Moved", "${connection.remoteInstance.url.toURI().toString()}/browse/$remoteIssueKey".toString())
                remoteIssue.status.name = "Done"
                StatusSync.receiveStatus(true, [:], remoteIssue, localIssue, nodeHelper)
                StopSync.stop(localIssue)
            } else if (IsSource.isDestination(localIssue, connectionId)) {
                IssueLinkSync.addRemoteLink(localIssue, remoteIssueKey, "Moved", "${connection.remoteInstance.url.toURI().toString()}/browse/$remoteIssueKey".toString())
            }
        }
)

Example snippet 2

  1. Sync issue from the source instance
  2. Set the remove issue key into a custom field on the source side

ExalateEventListener.hangListener(
 connection,
 { String localIssueKey, String remoteIssueKey, localIssue, remoteIssue ->
localIssue.customFields."Name of the Custom fields".value = remoteIssueKey
 }
)


Configuration

1. Create the file from the Exalate public repository

We store external scripts for Jira Server in a public repository.  Copy the code from the repositories below and create .groovy files. You must keep the file names as below.

2. Upload the file with the external script

You need to upload the .groovy file into the scripts directory

External scripts library location


Jira Server: $JIRA_HOME/scripts


2. Call the script from the Sync Rules

Once all external .groovy files have been uploaded to the proper directory, you need to call the script from the Sync Rules. 

Every .groovy file includes comments with a detailed explanation on how to use it. Please check the file comments.

Source side

Outgoing sync

ExalateEventListener.hangListener(
 connection,
 { String localIssueKey, String remoteIssueKey, localIssue, remoteIssue ->
    //  operation when remote issue has been Exalated 
 },
 {  String localIssueKey, String remoteIssueKey, localIssue, remoteIssue ->
    // operation when remote issue has been UnExalated
 },
 {  String localIssueKey, String remoteIssueKey, localIssue, remoteIssue ->
    // operation when remote issue has been Deleted
 }
)

See also