JIRA SERVER

This article show how to sync statuses using external scripts library.

Introduction

This page describes how to synchronize issue statuses between two JIRA Instances bi-directionally.


JIRA requires that status is updated by progressing an issue through the different workflows steps.  This can be done in different ways: 

A third approach is the one explained in this document, where the processor tries to find the shortest path to the appropriate status automatically, based on the mapping set in the script. 

Configuration

Let's consider you already have the Connection configured between two JIRA Instances.

Now you need to configure status synchronization: 

  1. Create files 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 files to the $JIRA_HOME/scripts directory

  3. Configure Sync Rules with the scripts provided below:

    Add the snippets below to the end  of the Sync Rules.

    Source side 

    Outgoing sync(data filter)

    StatusSync.sendStatus(replica, issue)

    Destination side

    Incoming sync for new issues(Create Processor)

    1. If statuses are the same on both sides, use this code:

      return CreateIssue.create(
        replica,
        issue,
        relation,
        nodeHelper,
        issueBeforeScript,
        remoteReplica,
        traces,
        blobMetadataList){
          StatusSync.receiveStatus(
            true,
            [:],
          replica,
          issue,
          nodeHelper
          ) 
         return null
      }

    2. If the statuses are different, use this code with your status mapping

      return CreateIssue.create(
        replica,
        issue,
        relation,
        nodeHelper,
        issueBeforeScript,
        remoteReplica,
        traces,
        blobMetadataList){
          StatusSync.receiveStatus(
          [
              "Source Status A" : "Dest Status A",
              "Source Status B" : "Dest Status B",
              "Source Status C" : "Dest Status C",
          ],
          replica,
          issue,
          nodeHelper
      )
         return null
      }

    Incoming sync for new issues(Change Processor)

    1. If statuses are the same on both sides, use this code:

      StatusSync.receiveStatus(
          true, 
          [:],
          replica,
          issue,
          nodeHelper
      )

    2. If the statuses are different, use this code with your status mapping

      StatusSync.receiveStatus(
          [
              "Source Status A" : "Dest Status A",
              "Source Status B" : "Dest Status B",
              "Source Status C" : "Dest Status C",
          ],
          replica,
          issue,
          nodeHelper
      )

See Also