1
0
-1

Hello
We have a Jira ticket synchronized with an Azure DevOps workitem. When the workitem ends and goes to the closed state and in Jira goes to the Resolved state, we delete the synchronization. Previously, we have saved in a custom field of Jira the id of the Azure workitem.
From Resolve, the user can close the Jira ticket and finish the process, but they can also disagree with the solution and reopen a new ticket.
In the case of reopening the Jira ticket, we create another workitem in Azure DevOps.
We want this new workitem to link to the previous workitem via a Predecessor link.
We have tried this code, but the link is not generated.


def await = { f -> scala.concurrent.Await$.MODULE$.result(f, scala.concurrent.duration.Duration.apply(1, java.util.concurrent.TimeUnit.MINUTES)) }
def creds = await(httpClient.azureClient.getCredentials())
def token = creds.accessToken()
def baseUrl = creds.issueTrackerUrl()
def project = workItem.projectKey
//def localUrl = baseUrl + '/_apis/wit/workitems/' + previousworkitem.id
def localUrl = baseUrl + '/_apis/wit/workitems/21743' + previousworkitem.id

def createLinkBody = [
[
op: "test,
path: "/rev",
value: 1
],
[
op: "add",
path:"/relations/-",
value: [
rel: "System.LinkTypes.Dependency-Reverse",
url:localUrl,
attributes: [
comment:""
]
]
]
]

def createLinkBodyStr = groovy.json.JsonOutput.toJson(createLinkBody)
converter = scala.collection.JavaConverters;
arrForScala = [new scala.Tuple2("Content-Type", "application/json-patch+json")]]
scalaSeq = converter.asScalaIteratorConverter(arrForScala.iterator()).asScala().toSeq();
createLinkBodyStr = groovy.json.JsonOutput.toJson(createLinkBody)
def result = await(httpClient.azureClient.ws
.url(baseUrl+"/${project}/_apis/wit/workitems/${workItem.id}?api-version=6.0")
.addHttpHeaders(scalaSeq)
.withAuth(token, token, play.api.libs.ws.WSAuthScheme$BASIC$.MODULE$)
.withBody(play.api.libs.libs.json.Json.parse(createLinkBodyStr), play.api.libs.ws.JsonBodyWritables$.MODULE$.writeableOf_JsValue)
.withMethod("PATCH")
.execute())


Why isn't the link being created?
Is it possible to copy in the description of this new workitem the last comment of the Jira ticket?

Thank you very much
Best regards

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi,


      I have reproduced the scenario on a test system and attached a video recording here: 



      The script I have used on ADO Incoming is attached here: Predecessor link.groovy

      And the Jira incoming is here: Jira.groovy


      Please let me know if you have any questions. 


      Thanks

      Majid

        CommentAdd your comment...