Hi Community,
Could automation (on Jira Software Cloud) figure out who was the last person to edit a specific field, and set a label if that person belongs to a specific Jira group? Is that even possible? If so, could someone outline approximately what that would look like? I would run the rule against a JQL filter as part of a one-time cleanup effort. Thanks for any ideas you can offer.
Kel
Ohai @Kelly Arrey and @Mikael Sandberg ...
*TECHNICALLY* you could use the REST API to get the changelog for every issue, like this:
https://YOURSITE.atlassian.net/rest/api/3/issue/BUG-5?expand=changelog
And then, maybe, you could filter every change for a specific field...
And then, maybe, you could grab the _last_ of those changes...
And then, maybe, you could identify the author of that change...
And then you could then do a check if that author is in a specific group
And IF SO, apply the label.
But this would all be a little hairy, for sure.
Maybe I'll give it a go later tonight. :-}
Thanks @Darryl Lee that sounds pretty hairy alright. Thanks for thinking about it but please don't spend any more time on it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Heh, I couldn't help myself. Got it to work, with the following caveat:
Anywho, we start with a Web Request to the Jira API:
https://YOURSITE.atlassian.net/rest/api/3/issue/{{issue.key}}?expand=changelog
Then we create a variable that I'm calling recentFieldChangers. What it's doing is getting the most recent changes to the issue (it maxes out at 100, hence the limit*), and checks to see if it is for the field Checkboxes. If so, then it outputs the accountId for whomever made that change (the author), and separates these accountIds with a semicolon.
{{#webResponse.body.changelog.histories}}{{#if(equals(items.get(0).field, "Checkboxes"))}}{{author.accountId}}{{^last}};{{/}}{{/}}{{/}}
Then I use the split function to turn that text string of semicolon-separated accountIds into a "list" object that I can select the first of:
{{recentFieldChangers.split(";").first}}
This is then fed to another web request to check if that user is in the selected group. (Automation does have a function to check if a user is in a group, but it can only be used against user fields in an issue, not arbitrary values.)
So that web request looks like this:
https://YOURSITE.atlassian.net/rest/api/3/user?accountId={{recentFieldChangers.split(";").first}}&expand=groups
I then create a variable called groupMatch. It is going through all the groups for that accountId from above, and checking to see if it matches the group named "shift2", and if so, it outputs "shift2":
{{#webResponse.body.groups.items}}{{#if(equals(name, "shift2"))}}shift2{{/}}{{/}}
And so, the last (heh) step is, compare whether {{groupMatch}} equals "shift2" and if so, then do whatever you need to do. In your case, apply a label.
Here's a picture of what this all looks like:
Notes:
* There actually isn't a limit to the number of changes you can view. But I'm using the issue API endpoint with the expand parameter. To check issues with more than 100 changes, you would have to figure out how to do pagination in the changelog API endpoint to go through each batch of 100 changes, AND they are sorted in chronological order, so you'd have to go through them backwards. I'm bad at doing this with real scripting languages, much less this "pretend" one. :-}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OH, and for your purposes, you would probably still manually trigger it, but run it against a JQL lookup, so then:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wow! Thanks again @Darryl Lee. I’m going to take some time to digest this and report back.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Heh, yeah, I realize it's a bit much. But hopefully you or somebody else can make use of it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes and no. You can set up the rule to trigger on when the field is changed and then check and see if {{initiator}} is in the specific group. But you cannot use a one-time rule to get the history of the issue to see if the user made the change.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Mikael Sandberg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I love how there are multiple correct answers in our world. 💙
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kelly Arrey
I'm not good with automation, but as an alternative solution, I can suggest Issue History for Jira app. Here, you can track Updated by field, so you will see what changes some person has made to the specific field. All standard and custom fields can be added to the report.
The app is developed by my team. You can try free online demo to see how it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Yuliia_Borivets__SaaSJet_, good to know!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.