Currently
I have ScripterRunner Cloud Listeners setup for Issue Updated, IssueLink created / deleted events.
Problem
I want to get the User that triggered these events, as I want to use the User to trigger new events.
e.g. issue = issue, event = event
But there is no "user" or "event.user"
I didn't work with Scriptrunner in Jira Cloud, but I know that on server you can get the change history with the ChangeHistoryManager and find out who the "author" of the change is.
So something like this could be an idea:
List<ChangeHistory> changes = ComponentAccessor.getChangeHistoryManager().getChangeHistories(event.issue);
ApplicationUser latestUser = changes.get(changes.size()-1).getAuthorObject();
If you can't use those things in scriptrunner, you'll have to get the issue changelog through the rest api and find the author of the latest change. (It's sorted by date starting from the oldest)
/rest/api/3/issue/{issueIdOrKey}/changelog
Thank you, @Matias Stachowski
This solution unfortunately does not work (or I am unable to get working) on ScriptRunner for Jira Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which part is not working? Did you try using the REST Api to get the last change in the changelog too?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@alexmears Did you ever found a solution.
We tried to implement an approach where an issue is updated under certain conditions, but that update triggered a new update event, which got processed again.
So the listener is not usable...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@francis ,
I got it working as well as we needed with:
if (changelog != null) {
if (binding.hasVariable('user')) {
println("initiating user = " + user.name)
} else {
println("initiating user is unknown")
}
};
Some events don't have a changelog, so we aren't getting the user for those.
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.