Join my YouTube channel and get free books.
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

Ravi Sagar Newsletter

Honestly I hardly send out mails but I guess there is no harm in at least having a newsletter. I will only send newsletter when I have something important to share or an update. People are busy and no one has time to read emails these days. If you really like my content then I guess you will remember my site and come back for more.

Want to contact me?