Logging with ScriptRunner script in Automation for Jira

Basit Rehman
Contributor
September 23, 2019

Hi there,

 

I am using 'Automation for Jira' to create some rules. In one of those rules I will have to run a ScriptRunner script as an action. My question now is if there is any possibility to make use of a logging functionality.

I know that Automation for Jira allows to use smart values in combination with the mustache framework to write something into the Audit Log.

But I am doing some calculations inside the script and need to know if everything is going fine. I even tried to use 'log.debug(...)' but it didn't appear in the Audit Logs of this rule.

Are there any solutions to this problem?

 

Best regards, 

Basit

4 answers

0 votes
John McKiernan
Atlassian Partner
September 23, 2019

Hey Basit,

John from Automation for Jira here. I think this would be a question for the Adaptavist support team.

As you mentioned, you can debug smart values (and anything else) with Automation for Jira: https://docs.automationforjira.com/getting-started/debug-a-rule.html#_2-debugging-smart-values

From this post, it seems like it is possible to debug scripts with Scriptrunner: https://www.adaptavist.com/doco/display/SFJ/Set+logging+to+help+debug+your+scripts

Lastly, thanks for answering the initial question @Jack. Just to clarify - there is an integration with Scriptrunner and Automation for Jira - but only for Server right now. (Just noticed Thanos also pointed this out above!)

https://scriptrunner.adaptavist.com/latest/jira/plugins/automation-for-jira.html

Hope that helps,

John 

Basit Rehman
Contributor
September 24, 2019

Hi John,

thanks for your answer. Debugging scripts with ScriptRunner already works for us. The thing is I would like to have these debug messages to be visible in the "Audit Log" that is provided with Automation for Jira. 

But I think you are right and this is a question for the Adaptavist team.:)

Like John McKiernan likes this
Sarah Kladstrup
Contributor
March 24, 2021

I think you're looking for the "addMessage("my message")" and "addError("error message text here")" features: https://scriptrunner.adaptavist.com/latest/jira/plugins/automation-for-jira.html#_binding_variables

Like # people like this
0 votes
Thanos Batagiannis [Adaptavist]
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 23, 2019

Hi Basit, 

I suppose you use something like the example in the documentation - https://scriptrunner.adaptavist.com/latest/jira/plugins/automation-for-jira.html

So if you use - in the script runner script - 

log.debug "This is a debug message"

Then you should be able to find this message in your application logs. But in order to be able to see debug messages you should first have to set the log level to debug for the ScriptRunner plugin.

Basit Rehman
Contributor
September 24, 2019

Hi Thanos,

thanks for your reply. Actually this setting is already in place for our Jira and I am able to see the logs in the application log file. However, it is better for our case that these logs should also appear in the "Audit Log" that is provided within the Automation for Jira add-on. Otherwise everyone who will create or modify some rules will need access to our server with the Jira installation even though the web frontend could be enough... Hope you understand this dilemma :)

Thanos Batagiannis [Adaptavist]
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, 2019

Hi Basit

Ok I see what you mean

 

Otherwise everyone who will create or modify some rules will need access to our server with the Jira installation even though the web frontend could be enough

Actually this was out thought and motivation behind View Server Log Files

If Automation tho has a kind of public API that allows you to write to Automation's Audit Log then you could use this as well. 

PS. Even tho I believe debug messages belong to application logs and not Audit logs.

Regards, Thanos

Basit Rehman
Contributor
September 25, 2019

Hi Thanos,

Actually this was out thought and motivation behind View Server Log Files

This is a good idea. I also thought of this workaround. But it would make me really happy for the future if it was possible to filter certain keywords in the log. Some kind of a 'grep' functionality you know?:)

0 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 23, 2019

There isn’t any integration between A4J and SR. I wish their was. You might contact Codebarrel and inquire.

Basit Rehman
Contributor
September 24, 2019

Hi Jack,

well you can use ScriptRunner as an action but unfortunately it is not possible to use its full potential.

0 votes
Jerzy Rud
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2019

Same problem here. Product is very unstable.

Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 23, 2019

Which product is unstable? If you are seeing an issue you should file a support request. I use A4J in cloud and while there are certainly some areas for improvement I have not found it to be unstable.

Like John McKiernan likes this

Suggest an answer

Log in or Sign up to answer