Finding issues that have moved projects

When using the REST API to update a ticket (XML-RPC), we have a use case where the ticket may have moved to a different project, but the client still knows it having the first key. ie, the issue was created having key AD-13362 but was then move to ED-236. In the actual Jira interface you could search for AD-13362 and ED-236 would come up, however this does not work with the API.

My question is, has anyone had a use case like this? And is there a workaround to have the API know that AD-13362 is now ED-236?

4 answers

1 vote

There is nothing possible using the current APIs. If you are okay to write a plugin, you can expose it as a new REST method!

I'm having the same problem - but I think there's an answer with the REST API. The reason I say that is that i'm using CURL - and if I grab all of the data in JSON format for one of my issues, moved from another project, there is an "inward" reference to the originating project. See below, an excerpt from a CURL query - the issue moved to is ENG-4500; the issue moved from is IECCH-3, and there are relations to 2 other issues - an ENG and an AH issue.

{"id":"58944","self":"https://[our company].jira.com/rest/api/2/issueLink/58944","type":{"id":"10010","name":"Related Issues","inward":"Related To","outward":"Related To","self":"https://[our company].jira.com/rest/api/2/issueLinkType/10010"},"outwardIssue":{"id":"67188","key":"AH-1221","self":"https://[our company].jira.com/rest/api/2/issue/67188","fields":{"summary":"Print Invoice","status":{"self":"https://[our company].jira.com/rest/api/2/status/6","description":"The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.","iconUrl":"https://[our company].jira.com/images/icons/status_closed.gif","name":"Closed","id":"6"},"issuetype":{"self":"https://[our company].jira.com/rest/api/2/issuetype/20","id":"20","description":"Bug","iconUrl":"https://[our company].jira.com/images/icons/bug.gif","name":"Bug SubTask","subtask":true},"priority":{"self":"https://[our company].jira.com/rest/api/2/priority/3","iconUrl":"https://[our company].jira.com/images/icons/priority_major.gif","name":"Major","id":"3"}}}},{"id":"58943","self":"https://[our company].jira.com/rest/api/2/issueLink/58943","type":{"id":"10010","name":"Related Issues","inward":"Related To","outward":"Related To","self":"https://[our company].jira.com/rest/api/2/issueLinkType/10010"},"outwardIssue":{"id":"83303","key":"ENG-4134","self":"https://[our company].jira.com/rest/api/2/issue/83303"...

and

there's a reference to "inwardIssue":{"id":"81331","key":"IECCH-3","self":"https://[our company].jira.com/rest/api/2/issue/81331",..

So there are references that can be accessed using the keys - extracting them easily seems to be the challenge at the moment. If I could craft a JSON and use a GET properly, I believe I could extract this info.

Jobin, am I mistaken? Or is it that it's not possible to craft a JSON entry that way?

inward and outward are used to show linking between the issues. It can be absent if there are no links. And it doesn't give you anything to show the old issue key. So you are looking at the wrong thing!

Ah, got it - because we are actually cloning the original issue and then moving the clone to another project. So the original issue is tracking the clone, and when we use the move issue wizard, JIRA substitutes the new project issue with the original cloned issue.

You're saying that if we moved the original issue, there would be no "track-back"? Clearly, there's some way for JIRA to do it - it's just that the REST API can't do so, if I understand correctly.

That's right! it is just the REST API can't do it, yet!

This should be resolved in JIRA 5.0 according to JRA-26806. Since I am still on JIRA 4.4.5 I have developed a workaround:

curl -I -sS -X GET --user username:password http://jira.example.com/browse/AKF-28522 | grep Location

If the issue has been moved you will get a Location back and it will contain the new issue key.

Can you search for issues that have changed projects in the GUI? So I want to search for projects that have moved from PROJA to PROJB on the search issues screen.

JQL Tricks plugin has a movedIssues function to do this. Might help.

I found I could use the the jira browse web interface and parse the html for the new ID.

http://jira.atsana.com/browse/JIRAPROJECT-123

will return an entry with the either the same JIRA ID or the actual JIRA ID:

<meta name="ajs-issue-key" content="ANOTHERPROJECT-567">

In Java using JSoup to parse the HTML it looks like this:

// returns the actual JIRA ID or null if the JIRA ID wasn't found

String actualJiraID(String jiraId){

String url = "http://jira.atsana.com/browse/";

String username = "user";

String password = "password";

String login = username + ":" + password;

String base64login = new String(Base64.encodeBase64(login.getBytes()));

Document doc = Jsoup.connect(url+jiraId).header("Authorization", "Basic " + base64login).timeout(10000).get();

// <meta name="ajs-issue-key" content="JIRAPROJECT-123">

Element element = doc.select("meta[name=ajs-issue-key]").first();

if (null == element){

return null;

}

String issuekey = element.attributes().get("content");

return issuekey;

}

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

816 views 2 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you