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.
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.
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%
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 ?
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.
In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to have–in order to produce a reliable long-term roadmap. We're tur...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs