Hello,
I am using a lot of groovy scripts lately but i need to change date everytime, my question is can i run groovy scripts from console?
for example:
I have script deactivateUser where i need to change login of user, and i want to run it like that from console
/script/deactivateUser.groovy arg1
where arg1 is username :)
I hope this is possible! If yes can you show me how to use arg1 in script and how to run it from console?
Thanks in advance!
Maciej O.
The easiest thing to do is to run it using the Script Console under Admin -> Script Console.
For example if you place your DeativateUser.groovy script under your script root (by default <jira-home>/scripts) so if you have it under "<jira-home>/scripts/userscripts/DeativateUser.groovy"
Your DeactivateUser.groovy script should have at the top:
package userscripts
Then the script you run in the Script Console would be:
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl def scriptRunner = ScriptRunnerImpl.getScriptRunner() // this is relative to the script roots def relativeFilePath = "userscripts/DeactivateUser.groovy" // change to your username you want to deactivate def username = "user1" scriptRunner.runFileAsScript(new File(relativeFilePath), [username: username])
You could even expand your script to take a list of usernames rather than just one.
Please see the docs here for information on script roots to double check you have your script in the correct place.
Hope this helps,
Thanks,
Adam
The easiest thing to do is to run it using the Script Console under Admin -> Script Console.
For example if you place your DeativateUser.groovy script under your script root (by default <jira-home>/scripts) so if you have it under "<jira-home>/scripts/userscripts/DeativateUser.groovy"
Your DeactivateUser.groovy script should have at the top:
package userscripts
Then the script you run in the Script Console would be:
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl def scriptRunner = ScriptRunnerImpl.getScriptRunner() // this is relative to the script roots def relativeFilePath = "userscripts/DeactivateUser.groovy" // change to your username you want to deactivate def username = "user1" scriptRunner.runFileAsScript(new File(relativeFilePath), [username: username])
You could even expand your script to take a list of usernames rather than just one.
Please see the docs here for information on script roots to double check you have your script in the correct place.
Hope this helps,
Thanks,
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The easiest thing to do is to run it using the Script Console under Admin -> Script Console.
For example if you place your DeativateUser.groovy script under your script root (by default <jira-home>/scripts) so if you have it under "<jira-home>/scripts/userscripts/DeativateUser.groovy"
Your DeactivateUser.groovy script should have at the top:
package userscripts
Then the script you run in the Script Console would be:
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl def scriptRunner = ScriptRunnerImpl.getScriptRunner()
// this is relative to the script roots def relativeFilePath = "userscripts/DeactivateUser.groovy"
// change to your username you want to deactivate def username = "user1" scriptRunner.runFileAsScript(new File(relativeFilePath), [username: username])
You could even expand your script to take a list of usernames rather than just one.
Please see the docs here for information on script roots to double check you have your script in the correct place.
Hope this helps,
Thanks,
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maciej,
The easiest thing to do is to run it using the Script Console under Admin -> Script Console.
For example if you place your DeativateUser.groovy script under your script root (by default <jira-home>/scripts) so if you have it under "<jira-home>/scripts/userscripts/DeativateUser.groovy"
Your DeactivateUser.groovy script should have at the top:
package userscripts
Then the script you run in the Script Console would be:
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl def scriptRunner = ScriptRunnerImpl.getScriptRunner()
// this is relative to the script roots def relativeFilePath = "userscripts/DeactivateUser.groovy"
// change to your username you want to deactivate def username = "user1" scriptRunner.runFileAsScript(new File(relativeFilePath), [username: username])
You could even expand your script to take a list of usernames rather than just one.
Please see the docs here for information on script roots to double check you have your script in the correct place.
Hope this helps,
Thanks,
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maciej,
The easiest thing to do is to run it using the Script Console under Admin -> Script Console.
For example if you place your DeativateUser.groovy script under your script root (by default <jira-home>/scripts) so if you have it under "<jira-home>/scripts/userscripts/DeativateUser.groovy"
Your DeactivateUser.groovy script should have at the top:
package userscripts
Then the script you run in the Script Console would be:
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl def scriptRunner = ScriptRunnerImpl.getScriptRunner()
// this is relative to the script roots def relativeFilePath = "userscripts/DeactivateUser.groovy"
// change to your username you want to deactivate def username = "user1" scriptRunner.runFileAsScript(new File(relativeFilePath), [username: username])
You could even expand your script to take a list of usernames rather than just one.
Please see the docs here for information on script roots to double check you have your script in the correct place.
Hope this helps,
Thanks,
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maciej,
The easiest thing to do is to run it using the Script Console under Admin -> Script Console.
For example if you place your DeativateUser.groovy script under your script root (by default <jira-home>/scripts) so if you have it under "<jira-home>/scripts/userscripts/DeativateUser.groovy"
Your DeactivateUser.groovy script should have at the top:
package userscripts
Then the script you run in the Script Console would be:
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl def scriptRunner = ScriptRunnerImpl.getScriptRunner()
// this is relative to the script roots def relativeFilePath = "userscripts/DeactivateUser.groovy"
// change to your username you want to deactivate def username = "user1" scriptRunner.runFileAsScript(new File(relativeFilePath), [username: username])
You could even expand your script to take a list of usernames rather than just one.
Please see the docs here for information on script roots to double check you have your script in the correct place.
Hope this helps,
Thanks,
Adam
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.