This article shows an example of how you can create an example groovy file, add a script and call it in the Sync Rules.

  1. Make sure you have the scripts directory 

    The directory location depends on the issue tracking platform.

    External scripts library location


    Jira Server: $JIRA_HOME/scripts

    Jira Cloud: opt/jcloudnode/data/scripts

    HP ALM/QC: opt/hpqcnode/data/scripts

    To get the folder for Jira Cloud please submit a support request, since Exalate app is hosted on our servers.

  2. Create BasicFieldSync.groovy file with the following code, and store it in the right location on your server.  There is no need to restart instance / add-on to enable the external script.

    class BasicFieldSync 
    {
      static receive(issue,
    		 		 replica,
    		 		 nodeHelper,
    		 		 commentHelper,
    		 		 attachmentHelper) {
    
        issue.summary      = replica.summary
    	issue.description  = replica.description
    	issue.assignee     = nodeHelper.getUserByUsername(replica.assignee?.username)
    	issue.reporter     = nodeHelper.getUserByUsername(replica.reporter?.username)
    	issue.labels       = replica.labels
    	issue.comments     = commentHelper.mergeComments(issue, replica)
    	issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
      }
    }

  3. Call the BasicFieldSync.groovy script from the Sync Rules 

    • Replace the script in the outgoing sync rules (create and change processors) as below:

      Existing script

      issue.summary      = replica.summary
      issue.description  = replica.description
      issue.assignee     = nodeHelper.getUserByUsername(replica.assignee?.username)
      issue.reporter     = nodeHelper.getUserByUsername(replica.reporter?.username)
      issue.labels       = replica.labels
      issue.comments     = commentHelper.mergeComments(issue, replica)
      issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
      New script
      BasicFieldSync.receive(
      		 issue,
      		 replica,
      		 nodeHelper,
      		 commentHelper,
      		 attachmentHelper
      )

Now you have one file with basic synchronization rules. You can reuse it in outgoing sync processors: new issues(create processor) and for existing issues(change processor)

If you add new code into the BasicFieldSync.groovy, it will be automatically executed in your incoming sync rules (create and change processors).


What's next

Now you can set up the advanced scripting environment and start working with Sync Rules using git.