How to transfer inline attachments from zendesk to jira

Originally asked by Francis Martens (Exalate) on 16 April 2020 (original question)


Inline attachments are handled differently on ZenDesk.
Anyway - the issue object is not including inline attachments into the issue.attachments array.

How can these be synnchronized.


Answer by Francis Martens (Exalate) on 16 April 2020

Solution

If you look at the content being sent in the comment containing attachments - it contains something like

​ !(https://d3v-francis.zendesk.com/attachments/token/AzEkdy3kmZ8X9MsqzAlG8Aarg/?name=hpalm-jira.png)​

By converting it into something like

!https://d3v-francis.zendesk.com/attachments/token/AzEkdy3kmZ8X9MsqzAlG8Aarg/?name=hpalm-jira.png!

Jira will be able to show the inline attachment.

:warning: Note that works only if the attaachments is accessible under that token. The day that the token is invalidated, the attachmetnt will not be reachable, so this is not really a solution.

Implementation

It is easy to replace the ![](<filename>) into !<filenname>! by using following construct

  1. Line 1 uses the mergeComments to iterate over all the comments in the replica and summons the closure to be run.
  2. Line 4 calls the replaceAll groovy string method. For each stringsegment matching the regexp a replacement is created. The replacement contains the necessary code to show the image with a maximum width of 512

Code is available here