Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,360,589
Community Members
 
Community Events
168
Community Groups

Is it possible to run a Scheduled ScriptRunner Job from inside a Post-Function?

Edited

I know I could just store the script in a file from within the "Script Editor" section of ScriptRunner, and then just use that for a Post-Function and a Scheduled Job, but I was wondering if there is a way to execute a scheduled job once from inside a Post-Function (so via Workflow Button) directly, as if you would press the "Run now" button on the jobs page manually.

Basically in pseudo code:

import com.onresolve.scriptrunner.scheduledJobManager

import com.onresolve.scriptrunner.scheduledJob

ScheduledJobManager scheduledJobManager = ComponentAccessor.getScheduledJobManager()

ScheduledJob scheduledJob1 = scheduledJobManager.getJob("JobThatDoesSomething")

scheduledJob1.run()

1 answer

Thanks for your reply.

I know how to write post-functions, and I read the documentation.

What I'm looking for is a way to import a custom Scheduled Job (that I created and runs every day) into a custom Post-Function script, and execute it from there (as if I pressed "Run now" on the Scheduled Job's page).

Welcome!
Copy the script to the post function, modify as needed, and be done with it. I know this isn't the answer you want, but you're asking to do something that "isn't easily possible." It is possible through the Java API, like every function in the app, but you should asses how much effort you are willing to put in and the value of the output. Cheers!

I see what you mean. I was hoping there to be a brief code snippet to do that, but I guess I can work with Script Runner's Script Editor too, and just have the code in a file as one central place, and then use that file as the job and the post-function.

Thanks.

Suggest an answer

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

Apps for Confluence you won't want to miss: RSVP for September's Appy Hours

Calling all collaborators and Confluence users! Our Appy Hours event on September 29th features 4 presenters demoing functionality to superpower Confluence. Don't miss learning about these apps i...

118 views 0 9
Read article

Atlassian Community Events