This article shows an example of how you can create an example groovy file, add a script, and call it in the Sync Rules.
Make sure you have the scripts directory.Custom scripts can only be deployed on Jira Server/Datacenter and nodes which are deployed through the docker deployment approach.
The directory location depends on the issue tracking platform.
Platform location Jira Server
There could be one of the following values instead of
snownodefor Exalate for ServiceNow.
adnodefor Exalate for Azure DevOps.
hpqcnodefor Exalate for HP ALM/QC.
Jira Cloud, just as any other cloud node, supports a set of specific scripts. Custom scripts cannot be deployed in this environment.
Check out List of external scripts for Jira Cloud for more information.
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.
Call the BasicFieldSync.groovy script from the Sync Rules
Replace the script in the outgoing sync rules (create and change processors) as below:
Existing scriptNew script
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).