This use case involves updating the parent field of a Jira issue during Exalate synchronization. Since Jira Cloud requires API-based updates for certain fields like parent
, the script uses the Jira Cloud REST API to dynamically update the parent field.
The process retrieves the local parent issue using the replica.parentId
, constructs a JSON payload with the parent issue key, and sends a PUT
request to the Jira Cloud endpoint /rest/api/3/issue/{issueKey}
. This ensures the child issue is correctly linked to its parent during synchronization.
Outgoing sync script (Source)
replica.parentId = issue.parentId
Incoming sync script (Destination)
if (replica.parentId) {
def localParent = nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())
if (localParent) {
def apiEndpoint = "/rest/api/3/issue/"+issueKey.id
def requestBodyJson = """
{
"fields": {
"parent": {
"key": "${localParent.key}"
}
}
}
"""
// Use the HTTP client to send the PUT request
def response = httpClient.put(apiEndpoint, requestBodyJson)
}
}