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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Start CURL from scriptrunner

Hi,
I try to resolve problem with Invalid Worklogs in Tempo after moving issue to another project. I wrote my own script based on this, but not work properly. I use My Groovy addon and I use CURL to serach and update date in Jira by REST API. My script find properly information in Jira, but I have problem with update a account filed. It’s look like curl2 isn’t execute. Can you take a look on my script and tell my where is a problem? I have another script listener where i execute curl command many time in one script and it’s work good. My Jira is install on Windows Server.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import groovy.json.JsonSlurper
def JIRA_API_URL = (“https://myjira.eu/rest/api/latest/issue/”)
def user_password = “user:password”
def accountCf = “customfield_11110”
def commentManager = ComponentAccessor.commentManager
def cfm = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByKey(“user”)
def issue= event.getIssue()
def projId = issue.getProjectId().toString()
def issueKey = issue.getKey().toString()
def curl = “E:/curl/bin/curl.exe -u user:password https://myjira.eu/rest/tempo-accounts/1/account/project/${projId}”
def output = curl.execute().text
def slurper = new groovy.json.JsonSlurper()
def results = slurper.parseText(output)
def id = results.id.toString()

def accountId = id.substring(1, id.length() – 1)
def sout = new StringBuilder(), serr = new StringBuilder()
def query = ‘{“””fields”””:{“””‘+accountCf+'”””:”””‘+accountId+'”””}}’
def curl2 = [ ‘E:/curl/bin/curl.exe’,(” -u “+user_password+” -X PUT –data “+query+” -H “+'”Content-Type:application/json”‘+” “+ JIRA_API_URL+issueKey)].execute()
curl2.consumeProcessOutput(sout, serr)
def error = curl2.waitFor();
def texto = sout.toString();
def texto2 = serr.toString();
log.debug(texto + “::” + texto2)
issue.store()

 

1 answer

Hi,

What do you get as a result of running script? Error?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

293 views 5 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you