I was wondering how to run a script using the ScriptRunner plugin when my Jira instance starts. Our custom scripts need some initialization to run correctly, and the current process is for the system admin to go run a startup script manually using the console.
I’m curious if there is an event I can listen for or part of the ScriptRunner API I can tap into. I did find that ScriptRunnerImpl does feature a runScriptsAtStartup method, but I am not sure what this does or if I can use it. My current best idea is to add a delay to the startup shell script after the jira command and then call a custom REST endpoint using curl, hoping that Jira is fully initialized when the call is made.
Part of me wonders if it’s time to develop a full-blown plugin.
If you put the script(s) in the package: "startup", it will be run run at jira startup. Similarly there is also pluginstartup, which runs on plugin enablement.... sounds like you want the former.
Thanks @Jamie Echlin _ScriptRunner - The Adaptavist Group_, that step worked and the script ran perfectly!
Now, part of the script initializes plugin.rest.scripts.package. Is there a way to call the custom rest scanner using groovy alone to lookup and add the REST endpoints (i.e. not with a request to /rest/scriptrunner/latest/custom/customadmin/scancustom, but with a method call?)
Thanks,
Sammo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not really sure why you need this... the "scan" function is only necessary if you add (or remove) a file under the script root that contains new rest endpoints, and you don't want to restart.
Restarting always does a scan... can you be more specific about what you are trying to do?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So when I set the system property “plugin.rest.scripts.package” to bar.foo.jira.rest (in my startup groovy script) and do the scan, it finds the endpoints. Will it remember them by itself when Jira restarts? How does it know to scan that package?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, I don't think it will remember them. The usual way of setting a system property is in the jira startup or setenv files, add -Dpropname=value.
Your way would work but seems unnecessary, best to set it in the same place all your other system properties are set.
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.
Hello @Jamie Echlin _ScriptRunner - The Adaptavist Group_ and @Sammo Gabay - I'm also trying to get a script to run on Jira startup.
I'm not 100% sure what you meant by adding the script to the "startup" package.
I placed the script in a folder named "startup" in script editor, and added "package startup" at the top of the script.
When restarting Jira, the script did not run.
Am I missing something?
Thanks,
Dan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.