Skip to content

Jira:Links:Imported Issue Links Broken

lbonanomi edited this page Jun 2, 2020 · 1 revision

After importing projects into a consolidated datacenter instance, issues with inter-Jira links are broken on import like so:

Recreate remotelinks as issue links

#!/bin/bash

THIS=$1

# Get issues relationships
#
curl -ns http://localhost:8080/rest/api/latest/issue/$THIS/remotelink | jq '.[] | "\(.id)@\(.object.url)@\(.relationship)"' | tr -d '"' | while read LINE
do

        NEWURL=$(echo $LINE | awk -F"@" '{ print $2 }' | awk -F"/" '{ print $5 }')
        RELATE=$(echo $LINE | awk -F"@" '{ print $3 }')

        RLBL=$(curl -ns http://localhost:8080/rest/api/2/issueLinkType | jq '.issueLinkTypes[] | "\(.name)@\(.inward)@\(.outward)"' | tr -d '"' | awk -F"@" '/'"$RELATE"'/ {print $1}')
        IN=$(curl -ns http://localhost:8080/rest/api/2/issueLinkType | jq '.issueLinkTypes[] | "\(.name)@\(.inward)@\(.outward)"' | tr -d '"' | awk -F"@" '/'"$RELATE"'/ {print $2}')
        OUT=$(curl -ns http://localhost:8080/rest/api/2/issueLinkType | jq '.issueLinkTypes[] | "\(.name)@\(.inward)@\(.outward)"' | tr -d '"' | awk -F"@" '/'"$RELATE"'/ {print $3}')

        if [[ "$RELATE" == "$IN" ]]
        then
                echo curl -ns -X POST -H \'Content-Type: application/json\' -d \'{ \"type\": { \"name\": \"$RLBL\" }, \"outwardIssue\": { \"key\":\"$THIS\"}, \"inwardIssue\": { \"key\":\"$NEWURL\" }}\' http://localhost:8080/rest/api/latest/issueLink | bash
        elif [[ "$RELATE" == "$OUT" ]]
        then
                echo curl -ns -X POST -H \'Content-Type: application/json\' -d \'{ \"type\": { \"name\": \"$RLBL\" }, \"inwardIssue\": { \"key\":\"$THIS\"}, \"outwardIssue\": { \"key\":\"$NEWURL\" }}\' http://localhost:8080/rest/api/latest/issueLink | bash
        fi

done

Clone this wiki locally