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

JIRA workflow transistion to run a script on server

Sanu Soman
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 2, 2013

Hi All,

Please let me know is it possbile to run a script on server as a part of JIRA workflow transistion?

Means, if an issue trasistion happens then a script has to run on server. Somehow is this possible in JIRA? Any third party plugin has this feature?

Please suggest.

Kindly let me know if my query is not clear.

Many thanks in advance.

Sanu P Soman

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
JamieA
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 2, 2013

The simplest way is just to use "ssh otherserver cmd"

Set up your private keys so there are no authentication prompts.

In script runner, the groovy script is simply:

"ssh otherserver cmd".execute()

The more long-winded way is to write an app on other server that provides a rest/soap or any other kind of API, and call it from the script.
Sanu Soman
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, 2013

I'm very much new to programmic world. Could you please provide some more details on ths.

Do you mean I need to add following line, "ssh otherserver cmd".execute() to the groovy script? If you don't mind, could you please provide one example to run shell script (script.sh) on a server (server1.domain.com) as part of workflow tansistion.

Sanu Soman
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, 2013

I'm very much new to groovy script. Could you please provide some more details on ths.

Do you mean I need to add following line, "ssh otherserver cmd".execute() to the groovy script? If you don't mind, could you please provide one example to run shell script (script.sh) on a server (server1.domain.com) as part of workflow tansistion.

JamieA
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, 2013

Nope, the above is a complete example. You put that in a file called something.groovy, and then in the post-function, choose "script function", and enter the path to that file.

JamieA
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, 2013

"cmd" in my example is the path to a shell script or other executable.

Sanu Soman
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, 2013

So then the groovy script content will be,

---------------------------------------------------------------------

"ssh server1.domain.com /location/script.sh".execute()

----------------------------------------------------------------------

??

JamieA
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, 2013

yes... maybe "ssh user@server" but I presume you will work that out. That's not a jira related issue.

Sanu Soman
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, 2013

Many thanks Jamie... it works:)

1 vote
Alexej Geldt
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 2, 2013

you can add postfunctions to transitions.

Imagine postfunctions as a TODO list of things that must happen when a transition is invoked. There are a couple of predefined postfunctions in jira such as change issue status, reassign etc... Maybe there is something that covers your needs?

If not, you have two options.

1. Use Scriptrunner Plugin as mentined above. This enables you to create new postfunctions and apply groovy scripts to them.

2. Make your own plugin and introduce your own new postfunction.

check this

http://www.j-tricks.com/1/post/2010/08/workflow-post-function.html

1 vote
Udo Brand
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 2, 2013

You can use the Scriptrunner Plugin. There you create own scripts for postfunction or use already existing ones.

Sanu Soman
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 2, 2013

Ok.. any idea with this how I can run a script (simple shell script to check a specific file on a dirextory ) on server (Not in JIRA server)?

Alexej Geldt
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 2, 2013

if that was possible, jira plugins would be able to steal any file from your server.

What are you trying to do actualy? if you just want to read some file, you must have it declared as resource.

Sanu Soman
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 2, 2013

I want to run a shell script on another server as part of issue workflow transistion.

Means, suppose an issue closing then a shell script has to run on a server.

Alexej Geldt
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 2, 2013

the other server must somehow expose this feature to your jira server.

lets say your Jira Server invokes a workflow transition and triggers a postfunction. This postfunction calls the other server and invokes a service which can start a shell script.

TAGS
AUG Leaders

Atlassian Community Events