Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Triggering an Automation For Jira rule from a workflow

Automation For Jira is an awesome part of the Jira toolbox. So awesome in fact that some of my clients don't purchase other apps that could make my life easier when I am implementing their business processes. One of the problems that I recently had to solve is how to trigger an Automation For Jira rule from a post-function.

In my case, the entire purpose of the transition is to execute this Automation for Jira rule, which updates a linked issue. I don't want to change the status of the trigger issue, just execute the rule when the user presses the transition button.

I came up with a couple of different ways that I could do this. One approach is to create a special custom field whose value I could change as part of the post-function. I could use the Field Value Changed trigger looking at this specific field and run it when the value of the field changed.

I rejected this for two reasons. First, as a Jira Administrator, I don't like to create custom fields that have no apparent value to the user and appears on no screens. Secondly, it creates an administrative problem because the next administrator has to rely on reviewing documentation to understand the purpose of this field. This is risky if the administrator is like me and likes to keep the Jira environment clean and tidy.

The approach that I settled on uses Automation For Jira's ability to be triggered as an incoming webhook. I created the Automation For Jira rule using the Incoming Webhook trigger. I then created an outgoing Webhook that calls this webhook passing the issue key. In the post-function, I use the Trigger a Webhook post-function to call the webhook. This triggers the rule on my issue. 

Do you have another way to trigger an A4J rule from a post-function? Do you prefer the "Field Value Changed" approach that I rejected?

8 comments

Hi Derek,

We have an issue open to track this at https://codebarrel.atlassian.net/browse/AUT-570

Pretty sure for now the workarounds you described are the only options.

Cheers,
Andreas

Like # people like this

Hi Derek,

My first idea would be to use custom event for this. e.g. throw "Run Automat" event, and then use trigger "Multiple issue events".

It is not like doing it in the post function, but it doesn't matter, because Automation for Jira don't start rules immediately.

Best regards,

Maros 

Like Martin Cleaver likes this

@Maros Strmensky ,

I had the same idea but A4J don't currently support custom events as trigger

https://jira.atlassian.com/browse/JSDCLOUD-4461

Like Martin Cleaver likes this

Did you ever figure this out? In the past I've done something very dumb, like have the transition add a value to a field, and then in the automation rule, check for that field, run the automation, and then delete the field.

Been looking at it again lately, and I think there is another way, but I haven't implemented it. You can do it by having the trigger for the automation be an external webhook, and then have the post function run an external webhook. It's convoluted though, in that you have to also add a webhook.

Frankly, I have no idea why one of the items in Post functions for transitions is not to run an automation rule. It's completely ridiculous.

Like Martin Cleaver likes this

I assume you are creating a System Webhook in Jira's central admin panel, the issue with that is it creates an association between something centrally managed (the egress webhook) to the something defined at the project level (the a4j rule to be invoked by it). And for every rule you'd need a system webhook.

On DC, my workaround was to create a set of System Events, and queue/process events in A4J. But it creates an obvious intermediate, doesn't scale and is asynchronous so the UI doesn't update immediately.

You couldn't use a single shared webhook because you couldn't pass in a parameter.

It would be simple for Atlassian to create a "invoke rule 164" with "{json payload}"; this would permit lookup of the rule by number/name. 

I was just thinking of doing the same... cataloging the a4j rules into a lookup table indexed by rule number. It's probably easy enough in ScriptRunner. Or someone could just write an Workflow Helper app that took parameters. 

Sadly AUT-570 is now 4 years old.

As an initial implementation, a workflow helper app could just take the a4j webhook url and the payload as parameters.

While ugly/fragile/obtrusive to embed the URL it'd avoid needing to build a rule number -> url-of--rule lookup. The numbers are a bit ugly in themselves.

Also, it would be nice if the rule implementing the webhook could have an elegant way to check it received all parameters it needed and return an error code otherwise.

I was asked by a colleague why it is needed to triggering A4J from a Transition at all, as Jira Automation can listen to a loop/any->itself transition. 

Of course, the reason is to bridge the post-function and a4j technologies. There are many reasons different projects use one or the other style for automation. Some might even use both, for instance if they are modernizing towards a4j.

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you