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()
Hi,
What do you get as a result of running script? Error?
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.