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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to run different script file in same Worflow Post function

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

2 answers

0 votes

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.

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 ?

0 votes

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)
}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

536 views 7 20
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you