You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Dear all,
I have a Worflow in Jira which is the same WF which is used by Jira Service Desk request for Adding a user and Adding new app.
In my Script Runner I have define 2 different files named accordingly AddUser.groovy and AddApp.groovy.
When the workflow goes to a certain transition, I am running a Post function custom script in which I was actually placing everything in same Inline code. That works.
But my idea is to split this 2 script in isolated files, but then how from the workflow I can specified to run the AddUser script file or AddApp script file ?
Is tehre a way to do this ?
regards
You could create yourself a utility class or one for each script
public class MyReusableMethods{
createUser(username){
//your code here
}
createNewApp(apppName){
//you code here
}
}
Then in your postfunction, you can just import the utility and call the methods
import MyReusableMethod
if(test){
MyReusableMethod.createUser(passingTheUserName)
} else {
MyReusableMethod.createUser(passingTheUserName)
}
No, a post-function can only run one script.
Either make two parallel transitions, or combine the scripts, adding logic that knows whether to do one part or the other.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply.
For example I have a main script file which main.groovy as below :
if (Test)
myNewUser.Create()
else
myNewApp.Create()
The Create() method of each object are in different script file which gets imported in main file using
import main
The workflow will call the main file script but inside it will merge code from other file script.
Will it work that way ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.