Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jira API issueLink connect two different instances

So, I have 2 different instances of Jira (let it be A and B), but they are connected with each other.

I can create manually a link in an issue within A, pointing to an issue within B instance. So, I can track issues from other instances. But how will I do it with an API?

If there will be one instance I will use this: https://docs.atlassian.com/jira/REST/latest/#d2e5606

Is there a way to determine where it should put the "outward" issue?

Just as an addition - I don't want to use remoteLink, as it's not the same (it's just a raw link and I need a real "connection" with statuses changing).

UPDATE

I have added an answer, example bash script could be seen there

like image 252
Stan E Avatar asked Apr 24 '15 14:04

Stan E


1 Answers

I found the answer.

1) We are making a query to the jira issue which are we going to link (endpoint is /rest/api/latest/issue/${JIRA_ISSUE})

curl -D- -u ${JIRA_U}:${JIRA_P} -X GET -H "Content-Type: application/json" -m 60 ${JIRA_SOURCE_LINK}

And extracting "id" field. This is the internal id of issue in jira "A"

2) Now we need to post a remote link to jira B '(/rest/api/latest/issue/${JIRA_ISSUE}/remotelink endpoint)' with the knowledge of what is the appId of jira A and what is the internal number of issue from (1) with type "com.atlassian.jira", see "globalId's" "issueId":

{
"globalId": "appId=0000-0000-000-000-000&issueId=101",
"application": {
    "type": "com.atlassian.jira",
    "name": "Jira name"
},
"relationship": "relates to",
"object": {
    "url": "https://jiraurl/browse/ISSUE-11",
    "title": "ISSUE-11",
    "icon": {},
    "status": {
        "icon": {}
    }
}

}

We will have it like: curl -D- -u ${JIRA_U}:${JIRA_P} -X POST -d '${JSON_TO_POST}' -H "Content-Type: application/json" -m 60 ${JIRA_LINK}

And it's done.

like image 172
Stan E Avatar answered Oct 22 '22 21:10

Stan E