capture scheduler time in variable in jira automation

Anna
Contributor
September 16, 2024

Hi there,

 

i have a scheduled trigger that checks for statuses of specific issues.

The trigger runs as per CRON expression 

 

every 0 0 9-14 ? * THU.

The last run should happen at 2 PM as per the scheduler. Is it possible to capture 2 PM as variable and use it in condition to see if it is a last run for the day? How we can capture the last run for the scheduled trigger in this case?

I need to implement logic of checking the statuses of relevant issues at last run and send email with final statuses at 2 PM.

 

Thanks,

Anna

1 answer

1 accepted

2 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2024

Hi @Anna 

Short answer: I do not believe that is possible, and even if it was, it may be unreliable.

 

The {{rule}} smart value provides the rule's name and the actor: {{rule.name}} and {{rule.actor}}.  It does not provide other information about the rule.  And, there is no public REST API yet to query the rule for other information.

And even if such information was present, there could be occasional cloud outages from Atlassian preventing the rule running exactly when you expected.  Indeed, information from Atlassian about what happens to the execution of scheduled rules after an outage resolves is undocumented.

 

I suggest there are a couple of workarounds for your scenario, which are based on knowing what values are defined in the trigger:

  1. Using {{now}} check if the rule is running on / after some time around 2 pm, and then perform your final status checks.
  2. Better still, use a second rule, triggered at some time after 2 pm to capture the final information for the day.  One advantage of this approach is the rule can be run manually after an Atlassian outage, regardless of the current time of day.

 

Kind regards,
Bill

Anna
Contributor
September 17, 2024

Hi Bill,

I was also thinking on using {{now}} as there are some date function for automation to try. I will try your suggestions. Really surprised on how deep your knowledge runs on these topics. Thanks a lot for your response!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events