How to Match Custom Field Sync Using External Scripts in Jira On-premise

    This article shows how to synchronize custom fields on Jira On-premise using External scripts library.

    Given that you have custom fields of the same types with the same names on both sides.

    When syncing custom fields it's important to make sure only the necessary custom fields are being sent over and are attempted to be applied. It is also important to find the proper value given the remote value. Exalate external script CustomFieldSync.groovy allows to sync custom fields without worrying of which ones should be synced or types of their values.

    Configuration

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

    Now you need to configure custom field synchronization: 

    • Configuration

    To configure custom field 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.

      • CustomFieldSync.groovy
    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

    CustomFieldSync.send([], replica, issue)

    Destination side

    Incoming sync 

    CustomFieldSync.receive(
        CustomFieldSync.logOnNoCfFound,
        CustomFieldSync.logOnCfContextMismatch,
        CustomFieldSync.defaultOnNoOptionFound,
        CustomFieldSync.defaultOnNoUserFound,
        CustomFieldSync.defaultNoVersionFound,
        CustomFieldSync.defaultCustomFieldTypeMismatch,
        [:],
        [],
        replica,
        issue,
        connection,
        nodeHelper
    )