It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
Hi
Can anyone help me how to configure a post function in a workflow for execute a shell script
Thanks & regards
Naidu . l
Should be possible with help of groovy, look this:
To execute a groovy script in postfunction you need the scriptrunner plugin
https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner/cloud/overview
Thanks for your response, but what i am looking is, I have a shell script in my local system and I want to execute it by using JIRA workflow (post function) please guide me how to configure it.
Thanks & regards
Naidu.l
You cant do this directly from Jira.
As i said, with the JIRA Plugin ScriptRunner you can execute Scripts in the programming languange groovy in a workflow postfunction.
in this groovy script you can then execute a shell script that is on the same system as your JIRA.
For better explanation i have this little shell-script that simply creates a textfile with a message:
#!/bin/bash echo "This is a Jira groovy to shell test" > /var/atlassian/application-data/jira/scripts/test.txt
Now i want to execute this shell script from jira:
First, as already said, i need the "ScriptRunner"-Plugin to be able to execute "Groovy"-Scripts in Postfunctions.
i now have this groovy script:
def sout = new StringBuffer(), serr = new StringBuffer() def proc = 'sh /var/atlassian/application-data/jira/scripts/testscript.sh'.exec$ proc.consumeProcessOutput(sout,serr) proc.waitForOrKill(1000) println sout
And in my workflow i add a postfunction to my transition thats execute the mentioned Groovy-Script:
groovyToShell.png
When i now execute the transition in the workflow it executes the groovy script which executes the shell-script and the textfile in my case is created.
I hope this helps!
If you pass the data you want to write to the shell script as a parameter, you can do whatever you want with it.
However, my "fix the actual problem" instincts are screaming here. "I want to write data to a file" is a solution to some problem, but it feels like it's probably a very poor solution.
Could you tell us what this file is for? There is a very strong chance that there is a *much* better way to meet your goal than writing data to a file.
Hi Nic
I am not passing any parameters from a file, to storing issue details to specific destinations custom post-function options of using third party plugins (script runner) is it possible ?
Thanks & regards
I don't know what that means.
You're trying to write data to a file with a script (probably a very poor way to achieve your goals). If you don't tell the script what you want to write, it can't write it.
I have create a issue in JIRA with a specific workflow and i give the all details(status, priority,components, label,Affect version, fix-version ) to my issue. Now i want to print those details into a text file using groovy script
I don't have any scripts. i am asking please share some scripts to store the issue details(type,priority, version) into a text file (/opt/text) through my post function configuration (when the state changed to resolved then execute my script and store the issue details into a particular location )
i don't groovy please share some scripts
kind regards
Apologies , i have only
shell script
#!/bin/bash
echo
"This is a Jira groovy to shell test"
> /var/atlassian/application-data/jira/scripts/test.txt
def sout =
new
StringBuffer(), serr =
new
StringBuffer()
def proc =
'sh /var/atlassian/application-data/jira/scripts/testscript.sh'
.execute ()
proc.consumeProcessOutput(sout,serr)
proc.waitForOrKill(
1000
)
println sout
>Why i am do this means I have store the all the binaries at one place by using the versions, this is the way easy to deploy the binaries per a required version numbers
That's a terrible way to "store the binaries", if I understand what that means. In fact, you don't need to do it at all, as all the information is in JIRA.
All you need to do to make your script work is add parameters. In the "def proc" line Stefan gave you, add the text required as a parameter, then in your script start with "echo $1" to see it come out.
Nearly, although I think you really mean what I am about to say.
You need to give the script parameters when you call it, and then you can use the data passed into it in the script.
suppose , I have to work on feature-1, then i was create a issue(task/bug) in JIRA and give the version detail like 1.0v (under affect version/fix version) right ? now i want to print the version details with in the same workflow is it possible ?
And one thing we have trigger to print the version details if the issue is in resolved state
I'm sorry, that still does not explain it.
Maybe if I knew what you were trying to achieve, I could get more from your explanations - some context often helps. What are you trying to give to the end user? Not how, but what should they see and why?
Could you please give me the context of what you are trying to do. I cannot make head nor tail of your explanations without that context. I don't care that it's an automation, I need to understand why you want to do this so I can understand what you are trying to get out of it.
I have maintain a central repository to store all my binaries with a version number(what i was given in JIRA issue) by manually but,
If we are able to print the issue properties/details then i can pass those value as a parameters to my next process
so i want asking to you is there any approach to print those value.
Thanks and regards
Ok, that's vague and doesn't tell us much more than you had before, but it's getting there. Some more questions
1.binaries means files like .war , ear .class.
2.from build/release team.
3.nexus repository.
4.see JIRA is mainly used for tacking and controlling right, in my case also use for tacking and control .
could please tell me one thing suppose, we have create a issue(task/bug/store)in JIRA then what details we are provide ?
Thanks & regards
Ok, great, that explains most of it. My question now is what the issues and versions have to do with your storage process?
As a side thought, why aren't your build/release team putting the binaries directly into Nexus?
Nexus is our binaries storage location why because, suppose we have released many versions(like 1.0,2.0,3.0..............................10.0) customer rise a bug on 5.0 then we can take the binaries(5.0) deploy it and easy to figure-out solution right(Is it environment problem or something else)
And I tried the following script for print the version of issue using post function its woking fine
import com.atlassian.jira.issue.Issue
import groovy.transform.BaseScript
import com.onresolve.scriptrunner.runner.customisers.ContextBaseScript
@BaseScript ContextBaseScript script
Issue issue = getIssueOrDefault("")
def response = issue.getFixVersions()
// create a file
def file = new File('/var/atlassian/application-data/jira/scripts/response.txt');
// save the response to it
file << response
Thanks & regards
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreHi Community! My name is Amir and I’m on the Jira Service Desk product marketing team at Atlassian. Our team would love to understand how you’re leveraging our ecosystem for Jira Service Desk. Wha...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.