Hello,
I have set up an automation rule (trigger Sprint Completed) to send an email listing all items added after the sprint began. When I manually test the rule, either before or after the sprint ends, the JQL functions correctly. However, when the rule is triggered automatically at the sprint completion, the JQL returns no results. Do you have any insights into why this might be happening or any potential workarounds?
The log message "Sprint ID {{sprint.id}}, Sprint Name {{sprint.name}}" returns the correct values both during testing and when the rule executes automatically (sprint completes), so the issue doesn't seem to be there.
The JQL used is: issueFunction in addedAfterSprintStart(<Board ID hardcoded>,{{sprint.id}})
This JQL is executed within a "Branch Rule" because some fields are otherwise inaccessible.
I hope this information is sufficient, but please let me know if anything is unclear. Thank you in advance.
Hello @Carlos Matta
Context and structure are critical in debugging an automation rule. Can you please share with us screen images showing your entire automation rule?
You said the JQL is executed "within a branch". How are you executing that JQL? Are you using a Lookup Work Items action?
How are you determining that the JQL is getting no results? What step following the execution of that JQL is not giving your the results that you expect if the JQL found issues?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am having issues with this interface (replying to all of you).... hope it works this time...
Hello, thank you both for your input. The rule functions perfectly when the trigger is set to "Manual". However, it does not work when the trigger type is "Sprint Complete" The logs display the correct {{}} values (highlighted in red in the screenshot). To address your questions:
I iterate through the results using #issues to construct the email body.
I can confirm that no results are being retrieved, as indicated by the Audit Log ("No related issues could be found") and the fact that the email is empty.
The {{sprint.id}} is used without quotes.
The option to execute only items since changed is NOT selected.
The query executes successfully in the JQL prompt UI and, as mentioned above, when running this script in manual mode the log shows all the Keys resulted from the JQL and the e-mail has all items expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adding the the suggestions from @Trudy Claspill ...
You appear to be using Jira Server (or Data Center). Is that correct?
And if so, you note using the plural {{issues}} smart value. That is only available when using the bulk-handling feature of branches or scheduled triggers. Did you enable the option?
https://confluence.atlassian.com/automation/run-a-rule-against-issues-in-bulk-993924653.html
If not, I would expect any references to {{#issues}} ... {{/}} to produce empty results.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the feedback. I have the option "Process all issues produced by this trigger in bulk" selected. While I am not entirely certain, I believe our Jira instance operates on a Data Center. Could this affect how the "Sprint Complete" trigger functions?
I am primarily trying to understand why the exact same query and automation rule work when the trigger is set to "Manual," but not when it is set to "Sprint Complete".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Carlos Matta
Thank you for all that great additional information.
Are you getting the addedAfterSprintStart() function from ScriptRunner?
When you say that it works when you trigger the rule manually, what sprint ID do you provide to the rule in that case? Is it the ID of an active sprint or a closed sprint?
When you say that the JQL works if you use it manually in the issue search, what sprint ID do you provide to the JQL in that case? Is it the ID of an active sprint or a closed sprint?
I ask because I wonder if there is a difference in the JQL results when used for a Closed sprint vs. an Active sprint. I don't have a DC/Server instance with ScriptRunner where I can test that out.
If all your manual testing is with a sprint id for an Active sprint, then I suggest you do manually testing with sprint IDs from a Closed sprint to confirm you get good results in that scenario. If you don't, that could account for the discrepancy since the rule would be using a Closed sprint ID.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, my responses below:
Are you getting the addedAfterSprintStart() function from ScriptRunner? Yes
When you say that it works when you trigger the rule manually, what sprint ID do you provide to the rule in that case? Is it the ID of an active sprint or a closed sprint? I hardcode the value. It is the same as what is printed in the action log ({{sprint.id}}) when "Sprint completed" ran. I have run it before the sprint ended (active sprint), and after the sprint completed (closed sprint), manually it worked both times.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for confirming it works manually for both active and closed sprints.
What version of Jira Server/DC are you using, and what version of the ScriptRunner app?
As a test, would you be able to try using the sprint name smart value (surrounded by quotes) instead of ID to see if that makes a difference?
I have not yet found anything in my internet searches to indicate there is a known problem with the function and the Sprint Completed trigger. I did find a 2024 post where another user mentioned not getting the right result when trying to use the function in a JQL Condition, but they did not provide information on the Trigger for the rule..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
My main challenge is testing the "sprint complete" event, as our board/project is used for corporate metrics, so I cannot freely create and close sprints at will. Do you have any suggestions on how to test in this context? I might consider using a different project.
I read the article from the link you provided, but I could not see how it applies to my situation. I suspect there might be another issue. We are using Jira v10.3.5, but I am unable to find the version of the ScriptRunner app since I am not an admin. Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Carlos Matta -- For testing a rule like this with Sprint Completed, creating a test project. You may create as many sprints as needed to repeatedly complete them. You wouldn't even need to finish the work items: just leave them in the sprint and keep moving them to the next one for testing.
Finally, when the rule works, you may re-create it or copy it to the target project.
And...I recommend simplifying your rule for testing in the separate test project:
sprint = {{sprint.id}}
issues in sprint: {{issues.size}}
Once that works as expected, change the JQL and re-test the changes.
This approach will help to isolate if the problem is in the ScriptRunner function used with rules, or something else.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
as @Trudy Claspill already mentioned it´s always helpful to add some more information/data to your question in order to see the whole situation.
Without having any of the details my best guess/first question would be if you the option is selected/deselected in your jql-branch that only issues will be taken into context that have been changed since last run of this rule (see screenshot).
furthermore:
did you set the smart value of sprint.id into quotation marks so it represents a string?
Best
Stefan
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.