Jira Cloud Scriptrunner - Find Issues that were moved from other Projects

Deleted user January 10, 2020

I recently stumbled over this Community Question:

https://community.atlassian.com/t5/Jira-questions/View-issues-that-have-been-moved-from-one-project-to-another/qaq-p/790346

I tried to run the Script, but it seams it would only work on Scriprunner for Jira Server

Since i am on Cloud and just starting to test Scriptrunner i wonder if somebody could help me get a working Script that gives me Issues that were moved from one specific Project to another specific Project for Scriptrunner Cloud.

Thanks

Best Wishes

Michael

2 answers

2 accepted

1 vote
Answer accepted
Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2020

Going forward you can configure a notification in the notification scheme for "issue moved".

Deleted user January 14, 2020

Thanks for the Advice. I didn't think of that.

Best Wishes

Michael

0 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 10, 2020

Hi Michael,

Thank you for your question.

I have checked your requirement and can confirm it is not possible to use ScriptRunner for Jira Cloud to track the details of when a ticket is moved between issues and to post this information on an issue when it is moved.

The reason for this is that Atlassian does not provide a webhook that can be used to run code when an issue is moved using the built-in Move Issue functionality provided by Jira.

However, I can confirm that the closest thing you could do with ScritpRunner for Jira Cloud would be to configure a Script Listener which is configured to fire on the Issue Created event.

The listener code would then post a comment to the created issue with the original key of the issue so that you have this information documented on the issue when it is created and before it is moved to another project.

I can confirm that we have an example of how to add a comment on an issue when it is created inside of the documentation page located here.

You would then be able to search issues which have the comment added to see if the original issue key was from a different project.

I hope this helps.

Regards,

Kristian

Deleted user January 13, 2020

Hallo Kristian,

i think you missunderstood my Usecase. I want to find out which Issues were moved from one specific Project to another specific Project. I don't want to change or Comment on the Issues and i want to do it in retrospect.

Is it not possible to access History Data from Issues in Scriptrunner Cloud? I didn't find Examples so far.

Best Wishes

Michael

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 13, 2020

Hi Michael,

Thank you for your response.

I can confirm that it is possible to get the Change History for an issue by making a call to the Get Changelogs Rest API which Atlassian provides and is documented here.

Using this API you will be able to return the Change History from an Issue and you will be then able to write some logic check in the history returned if the issue has moved projects.

I have just created a small example located here which you can run on the script console in order to return the change history for an issue and you can use this as a reference guide to see how to use this API and to check in what in format the data is returned.

I hope this helps.

Regards,

Kristian

Deleted user January 14, 2020

Hallo Kristian,

thanks for your Response.

Is there no other way, than to access all the Issues complete Changelogs?

def destProject = "AAA"

def result = get("/rest/api/3/search?jql=project=${destProject}&fields=summary&expand=changelog")
.header('Content-Type', 'application/json')
.asObject(Map)
.body

And then check each if the Key was changed?

The next Problem would be the Paging of the Search.

The Example in https://community.atlassian.com/t5/Jira-questions/How-to-find-issues-that-were-moved-from-one-project-to-another/qaq-p/49115 uses a ChangeHistoryManager Class. is that or something similar not available in the Cloud Version?

Best Wishes

Michael

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2020

Hi Michael,

I can confirm that the example linked above will not work on Jira Cloud due to the fact that the code provided inside of it is for ScriptRunner for Jira Server and this will not work as Atlassian only provide a rest API in Jira Cloud and do not provide a Java API in the cloud-like they do in Jira Server.

 Unfortunately in Jira Cloud, the only API to get the Change Logs is the one linked above as Atlassian does not provide another API where you can get the Change Logs for a set of issues specified.

This means that you will need to write some logic in your code to call this API for every issue key returned from your search in order to get the changelogs for each issue.

I understand this response is frustrating but please understand that this is the only way to get the Change Logs as this is the only API that Atlassian provide for this inside of Jira Cloud.

I can also confirm that for the Search API that Atlassian provides a maxResults parameter as described in the API documentation page located here which as stated in this page defines the maximum number of items to return per page.

I hope this helps.

Regards,

Kristian

Deleted user January 14, 2020

Hallo Kristian,

thanks for your Answer you saved me the time to look further before i start to code something.

Can i somehow save the Script within Scriptrunner, like the Built in Scripts or is the only option to copy it into the Console again?

Best Wishes

Michael

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2020

Hi Michael,

I can confirm currently we do not provide any ability to save scripts as a built-in script currently.

This means we would advise saving the script somewhere such as a Git repository and then to copy the code from here into the Script Console page each time you wish to run the script.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events