Jira Courses, Training and Consulting: Sparxsys Trainings
Thanks for coming here, I hope you are enjoying learning here, I have also written some books in case you want to learn a bit more :)
If you need my help with Drupal, Linux, Jira, Scripting, Automation or want to contact me then raise a ticket for me please :) and I will get back to you, promise. At Sparxsys we provide Atlassian consultancy services, reach out to me at ravi at sparxsys dot com

Access Jira issue's change history using Automation

There were few questions on the community related to using smart values for fetching change history of an issue. It is much easier to use ScriptRunner for Jira Cloud but there is something that can be done using Automation as well.

I would prefer using ScriptRunner as writing a groovy script is easier, a bit more readable and can handle complex cases. In both cases you need this end point.

  1. JIRAURL/rest/api/3/issue/{{issue.key}}?expand=changelog

Let us say you want to do it using Automation rules, then when you call this end point. You will get a response JSON back in a smart value which you can access like this.

  1. {{webhookResponse.body.changelog.histories}}

Now if you log this smart value you will get the json of the histories part of all the change histories. Now you can further iterate over those list of items in the change histories.

  1. {{#webhookResponse.body.changelog.histories}}
  2. ID: {{id}}
  3. Created: {{created}}
  4. {{#items}}{{fromString}} - {{toString}} {{/}}
  5. {{/}}

This will give you all the items in the change log like this.

  1. ID: 18206
  2. Created: 2021-01-02T17:11:59.730+0000
  3. To Do - In Progress
  4.  
  5. ID: 18152
  6. Created: 2021-01-01T16:40:30.859+0000
  7. To Do - In Review

I hope it helps.

Syndications

Webmentions

Reposted by vdtobon on Fri, 03/12/2021 - 15:43

Similar posts

Subscribe

* indicates required

Please confirm that you would like to from Sparxsys:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices.

Want to contact me?