I want to provide a mechanim to automate the addition of new options to a select list in our Jira system. I have written a groovy script that does all the heavy lifting and uses the JIRA API to add the provided Options to the select list.
Using the ScriptRunner Script Console, I can run my script and have verified the functionality is correct. The final missing link is finding a way to remotely trigger/execute the groovy script without having to rely on being logged into the Jira GUI.
Does anyone know of a curl/wget/anything-based solution that would allow me to populate the "Script File Path" field on the groovyRunner Script Console page and then trigger the "Run" button? I've been scouring the interwebs for an example of someone doing this, but have come up shy.
Thanks.
Have you got chrome? If you press f12, run the script from the UI, and look at the network tab. Right-click on the request, there is an option "copy as curl".
Remove all the cookie crap and other stuff and you have what you want, although you will probably want to add "--user username:password" for http basic authn.
Thanks for the reply Jamie. Going to give this a try tonight and will update then.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Worked beautifully Jamie, thank you very much.
For the benefit of others, here's an example of a Windows batch file for triggering a Script Console script remotely:
@echo off rem Script to run a Jira script on the ScriptRunner Console remotely. set USERNAME=admin set PASSWORD=secret set DASHBOARD_URL=http://localhost:8080/secure/Dashboard.jspa set SCRIPT_CONSOLE_URL=http://localhost:8080/secure/admin/groovy/GroovyRunner.jspa set COOKIE_FILE=jiracoookie set SCRIPT_TO_RUN=C:\helloWorld.groovy "C:\Program Files\cURL\bin\curl.exe" -u %USERNAME%:%PASSWORD% --cookie-jar %COOKIE_FILE% --output output1.txt %DASHBOARD_URL% "C:\Program Files\cURL\bin\curl.exe" --cookie %COOKIE_FILE% --header "X-Atlassian-Token: no-check" --data "filename=%SCRIPT_TO_RUN%" --data "Run+now=Run+now" --output output2.txt %SCRIPT_CONSOLE_URL% erase %COOKIE_FILE%
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In case anyone wants to see this in bash, I have some sample code for you: https://answers.atlassian.com/questions/284007/how-to-call-canned-builtin-script-runner-scripts-from-a-script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It helped a lot Jamie
I changed the cURL a little bit and requested the script from directory. scriptFile=/var/..........clear.groovy"
I would like to run the code but each time I have different variables (dynamic data). Such as posting with different issuekeys. Is it possible ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tansu, I have found that the best way to accomplish what you're trying to do is to create a custom Built-In script that sits along side the ones that are bundled/provided by Jamie. These scripts can have input parameters, and can be tested locally from the "Built-in Scripts" console. When you're satisfied everything works, you can then trigger a curl request to populate the script form, sending as input your dynamic parameters. This amounts to the same concept described above, only you use the Build-in Scripts interface rather than the Script Console interface. Hope that helps.
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.