ScriptRunner Cloud - Listener - Objects

This is about ScriptRunner for Cloud

We are in the mid of configuring a private to private type of synchronization where both Jira Instances are behind a firewall, where the firewall cannot be opened for inbound connections.

Given that Exalate allows to do a private to public type of synchronization, and it does support fan out, we will be using a Jira Cloud instance as gateway between the two private instances.

The problem we are trying to work around is that Exalate will not sync issue events caused by itself (else it would loop forever)

ScriptRunner to the rescue - we thought. Whenever an issue is updated by Exalate, just update the issue (to trigger an update event by the ScriptRunner user), and there it goes.

Also here, you want to avoid loops (but then caused by ScriptRunner), so we added a condition at the top of the script listener. But it appears that the user object is only available for issue related events.

As we didn’t find any documentation on the subject, we wrote a small groovy script which prints out all the objects available for the different events

logger.info("Webhook Event Type Name '${webhookEvent}'")

switch (webhookEvent) {
    case ~/.*attachment_.*/:
        logger.info("Attachment ${attachment?.keySet()}")
        break
    case ~/.*comment_.*/:
        logger.info("Comment ${comment?.keySet()}")
        logger.info("Issue   ${issue?.keySet()}")
        logger.info("Issue   ${issue?.fields?.keySet()}")

        break
    case ~/.*issue_.*/:

        logger.info("Issue   ${issue?.keySet()}")
        logger.info("Issue   ${issue?.fields?.keySet()}")
        logger.info("User       ${user?.keySet()}")

        break
     case ~/.*issuelink.*/:
        logger.info("IssueLink       ${issueLink?.keySet()}")
        break  

    
}

This is the output for the different events

Attachment Created,

This is interpreted as an issue updated - which looks like a bug

Attachment Deleted,

2019-09-21 13:10:54.928 INFO - Webhook Event Type Name ‘attachment_deleted’
2019-09-21 13:10:54.930 INFO - Attachment [self, id, filename, author, created, size, mimeType, content, thumbnail]

Comment created

2019-09-21 13:10:17.778 INFO - Webhook Event Type Name ‘comment_created’
2019-09-21 13:10:17.792 INFO - Comment [self, id, author, body, updateAuthor, created, updated, jsdPublic]
2019-09-21 13:10:17.794 INFO - Issue [id, self, key, fields]
2019-09-21 13:10:17.811 INFO - Issue [summary, issuetype, project, assignee, priority, status]

Comment deleted

2019-09-21 13:10:19.775 INFO - Webhook Event Type Name ‘comment_deleted’
2019-09-21 13:10:19.792 INFO - Comment [self, id, author, body, updateAuthor, created, updated, jsdPublic]
2019-09-21 13:10:19.793 INFO - Issue [id, self, key, fields]
2019-09-21 13:10:19.811 INFO - Issue [summary, issuetype, project, assignee, priority, status]

Comment Updated

2019-09-21 13:10:28.793 INFO - Webhook Event Type Name ‘comment_updated’
2019-09-21 13:10:28.812 INFO - Comment [self, id, author, body, updateAuthor, created, updated, jsdPublic]
2019-09-21 13:10:28.813 INFO - Issue [id, self, key, fields]
2019-09-21 13:10:28.831 INFO - Issue [summary, issuetype, project, assignee, priority, status]

Issue Created,

2019-09-21 13:11:22.949 INFO - Webhook Event Type Name ‘jira:issue_created’
2019-09-21 13:11:22.950 INFO - Issue [id, self, key, fields]
2019-09-21 13:11:22.950 INFO - Issue [statuscategorychangedate, fixVersions, resolution, customfield_10113, customfield_10114, lastViewed, …, duedate]

Issue Deleted,

2019-09-21 13:10:53.861 INFO - Webhook Event Type Name ‘jira:issue_deleted’
2019-09-21 13:10:53.892 INFO - Issue [id, self, key, fields]
2019-09-21 13:10:53.894 INFO - Issue [statuscategorychangedate, fixVersions, resolution, customfield_10113, customfield_10114, lastViewed, …, duedate, comment]

Issue Updated,

2019-09-21 13:11:24.329 INFO - Webhook Event Type Name ‘jira:issue_updated’
2019-09-21 13:11:24.348 INFO - Issue [id, self, key, fields]
2019-09-21 13:11:24.348 INFO - Issue [statuscategorychangedate, fixVersions, resolution, customfield_10113, customfield_10114, lastViewed, …, duedate]
2019-09-21 13:11:24.368 INFO - User [self, accountId, emailAddress, avatarUrls, displayName, active, timeZone, accountType]

Issuelink Created,

2019-09-21 13:17:40.728 INFO - Webhook Event Type Name ‘issuelink_created’
2019-09-21 13:17:40.787 INFO - IssueLink [id, sourceIssueId, destinationIssueId, issueLinkType, systemLink]

Issuelink Deleted

2019-09-21 13:17:31.130 INFO - Webhook Event Type Name ‘issuelink_deleted’
2019-09-21 13:17:31.188 INFO - IssueLink [id, sourceIssueId, destinationIssueId, issueLinkType, systemLink]

Hope it is useful for someone

1 Like