How to remove remote links in bulk

Description

We like the ability to link issues to Confluence pages and inversely. The fact that JIRA and Confluence automatically create a reverse link is also a nice feature. Unfortunately, the reverse links that Confluence creates in JIRA are very generic if you are not currently authorized to view the page. Basically they say mentioned in Page. It is hard to know what information is on the page and whether you even will have access if you authenticate. It becomes a trial and error exercise. This becomes really annoying if you have a bunch of links that all look the same. More over, there doesn't seem to be away to NOT reverse link when you are creating a JIRA issue reference in Confluence. In our case, we had created various pages linking back to JIRA issues, many to the same issue and most did not provide a useful link for anybody. The result was some issues being cluttered with 10's of links of no value. And worse, they obscured the one link that was meaningful. How could be get rid of the unwanted links in JIRA? More over, how could we do this without removing meaningful links? 

Analysis

We used getRemoteLinkList to analyze the problem. We had hundreds of remote links, but we could not tell what Confluence pages were being linked to :(. We needed more information and needed a JCLI improvement to do it:  JCLI-891 - Getting issue details... STATUS . Now we were able to get the list of remote links including the space and page they linked to. From that we determined the majority of the problem (about 200 meaningless links) was related to some specific status pages. 

Solution

We could easily define a regex pattern that would identify pages whose links we wanted eliminated. Because the linked site required unique authorization to access the Confluence page, we had to add targetUser and targetPassword parameters. We constructed a JQL that identified virtually all the issues on the site and let the magic happen automatically with a single action. While it took a while to go through the entire site, we were done and all the pesky links were gone and the good ones were still there (wink).

--action runFromIssueList --common " --action runFromRemoteLinkList --issue @issue@ --regex2 \".*Status report.*\" --targetUser automation --targetPassword "********" --common \"--action removeRemoteLink --issue @issue@ --name @remoteLinkId@ \" " --jql "project not in (XXX) order by key"

Note : To remove all remote links of a single issue.

--action runFromRemoteLinkList --issue issueKey --common "-a removeRemoteLink --issue issueKey --name @remoteLinkId@"