Copy Attachment from JIRA issue to Insight Object

Eric Collins
Contributor
August 27, 2018

Does anyone have an example of coping an attachment in JIRA to and Insight object?

2 answers

0 votes
Ksenia Abdulina April 15, 2024

Hi @Eric Collins 

I use this construction for adding existing csv file from issue to insight object: 

import com.atlassian.jira.issue.AttachmentManager

import com.atlassian.jira.issue.attachment.Attachment

import com.atlassian.jira.util.AttachmentUtils
import customRiadaLibraries.insightmanager.InsightManagerForScriptrunner

InsightManagerForScriptrunner im = new InsightManagerForScriptrunner()

def aM = ComponentAccessor.getAttachmentManager()

def pM = ComponentAccessor.getAttachmentPathManager()

def attachments = aM.getAttachments(issue)                

   if (attachments != null){

      def fileName, filePath

      attachments.each {a ->

        fileName = a.filename

        filePath = AttachmentUtils.getAttachmentFile(a)                    

      }

        def domainObjectAttachment = im.addObjectAttachment(objectId, filePath, fileName,"",false)

   }



Where objectId is your obkect key. Hope that helps.

0 votes
Zihni Saglam
Contributor
September 14, 2018

Hi Eric

Insight doesn't have a built in function to copy attachments from Jira/JSD to an Insight object. 

We do have a REST API call which you can find on our documentation page here to add attachments to objects. 

Regards,

/Zihni

Eric Collins
Contributor
September 14, 2018

Thank you, I will get that a shot.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events