Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Returning values from Scriptrunner to Automation

Martin Cleaver
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.
August 17, 2021

From Jira Automation, we'd like to pass values back from calling Scriptrunner. (I have various scenarios where I want to do this, the most common of which is to call an external REST API and deal properly with error codes. A4J aborts any automation on receiving a 404.)

Ideally return values established in Scriptrunner are made available to Automation. I want to keep it as Automation's job to edit the issue so it's clear to the casual nocoder what is going on. 

Is this possible? I'm on DC.

Thanks,

   Martin

1 answer

1 accepted

2 votes
Answer accepted
Martin Cleaver
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.
August 18, 2021

So it looks like the right way to do this is to define a REST endpoint and call that from a waiting WebHook in Jira Automation. (Kudos to @Tom Hudgins on Need value of automation rule initiator in scriptrunner script for his comment about a workaround.)

Even if there is another way, using REST follows the principles of following an existing standard for communicating between different systems, and keeping things as loosely coupled as possible.

The REST API should be set up to guard for permitted APIs. It could be hosted on AWS Lambda/Forge or ScriptRunner or PowerScripts, depending on how future proof the architecture needs to be.

Of course, it would be nice if Scripting solutions for Jira just wrapped the REST call in quasi parameter and return call semantics. i.e. called REST for us and waits for the answer, passing back values via an unpacked webhook response. As it is, you can invoke only with no sense of instructing behaviour or knowing outcome.

Gareth Cantrell
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 3, 2021

If you only need to call a REST endpoint to setup a webhookResponses smart value list to use in later scripts, you can do a GET web request to http(s)://your.jira.host/status.

This is a very quick call which requires no authentication and avoids the need to set up a separate REST endpoint in scriptrunner.

Like Martin Cleaver likes this
Martin Cleaver
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, 2021

Seems like the values are set by side effect.

So relying on it could break silently down the road.

Martin Cleaver
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 24, 2021

That said, I'll play with this - I suspect I passed judgement too quickly.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events