Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,059
Community Members
 
Community Events
176
Community Groups

I can update the attachment whit groovy CLOUD

I have this code to update the new SubTask in  transition, but I have problems to put the news attachments:

Captura.PNGCaptura2.PNG

 

2 answers

2 accepted

2 votes
Answer accepted

I found this code, and tested it. It works fine, you could addapt it for your purpose:

import org.apache.http.entity.ContentType

def getIssue = 'SD-3'
def result = get('/rest/api/2/issue/' + getIssue)
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200){
logger.info('sucess')
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}

result.body.fields.attachment.collect {
attachment ->
def url = attachment.content as String
url = url.substring(url.indexOf("/secure"))
def fileBody = Unirest.get(url).asBinary().body
def postIssue = 'SD-4'
def postResult = Unirest.post("/rest/api/2/issue/" + postIssue + "/attachments")
.header("X-Atlassian-Token", "no-check")
.field("file", fileBody, ContentType.create(attachment['mimeType'] as String), attachment['filename'] as String)
.asObject(List)
assert postResult.status >=200 && postResult.status < 300
}

Regards 

Muchas gracias Alejandro;

Es justo lo que necesitaba:

 

It was wonderful, cause is Exactly that I need.

Thank's

Like Alejandro Suárez likes this

For all the people that need a similar Script or same Script, In CLOUD is very important (in this case) to put the import class.

import org.apache.http.entity.ContentType

Because if not put, it will be an error

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events