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 !!!
The Script Runner add-on adds a Script Post-Function that you can utilize.
Inside a Workflow, there are Statuses like
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:
"ssh domain.com CustomShellScript.sh".execute()
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you considered Webhooks (https://confluence.atlassian.com/display/JIRA/Managing+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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much guys for quick turnaround.. I really appreciate it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"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."
May I know how you did this? I also need to trigger a script through a transition but that script needs the details of the specific issue that triggered it. I still can't figure out how to do that part.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.