Triggering script on some acction?

Hi all,

I am trying to work on some automation,  where if manager approves some request, I want to call script which ssh to some servers and execute commands and paste output in comments section.


Thanks in advance !!!

4 answers

This widget could not be displayed.

The Script Runner add-on adds a Script Post-Function that you can utilize.

Inside a Workflow, there are Statuses like YellowIn Progress or Greenclosed. We can perform a sort of action when we are on a Status, like move from In Progress TO Closed, or perhaps move from In Progress to In Progress. These actions are called Transitions. On a Transition, we can add constraints or checks of sorts. We can also perform actions. These are called Conditions, Validators, and Post-Functions.

A Post-Function fires AFTER a Transition has occurred. This implies our logic should be determined in the Conditions and Validators, and our Script Post-Function should only be performing as simple of an action as possible. For instance: We should add a Condition to the Transition, so that only Manager can utilize the Approve Request. We should not utilize our Script for this.

To SSH, we can ssh using a script like so:



This doesn't solve the request to paste output in the comments section. I don't believe we should be relying on a post-function to do this. Your remote script should reach out to JIRA via the REST API to add a comment itself. 

curl -D- -u user:user -X POST --data { "body": "This is a comment regarding the quality of the response." } -H "Content-Type: application/json" http://example:8080/rest/api/2/issue/EX-50/comment

This widget could not be displayed.

Yes you can. What you can do is create a transition in your issue called "Approve" then for this transition, add a post-function called "Script Post-Function" on which you will need to supply the path of your script. 

The callback is tricky but I have the same requirements before. So what I did was I pass the JIRA issue number in the script which do some work and afterwards update that issue number with a separate JIRA API call.

This widget could not be displayed.

Thank you so much guys for quick turnaround.. I really appreciate it.

Steven Behnke Community Champion Aug 20, 2015

No problem

This widget could not be displayed.

So idea for this automation is:

Engineer creates a ticket, put one or multiple strings and submit. Ticket goes for approval and ones it gets approved the script kicks off. The script should take that string from the ticket, ssh to server, execute that string and paste output to comment section.

Any idea how to tell my script to grab strings from the ticket? If I figure out how to tell my script to do that everything else should be easy after that.


Steven Behnke Community Champion Aug 20, 2015

Have you considered Webhooks ( You can use a "post-function webhook" to fire a Webhook to a URL, which would include issue details. Then your script could lift them from the JSON payload instead of having a Script Runner script try and pass the issue details. Perhaps this would be a more straight-forward implementation.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

521 views 3 19
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you