This plugin adds the ability to directly execute Groovy code.
To configure available Groovy installation on your system, go to Jenkins configuration page, find section 'Groovy' and fill the form as shown bellow.
To create Groovy-based project, add new free-style project and select "Execute Groovy script" in the Build section, select previously configured Groovy installation and then type your command, or specify your script file name. In the second case path taken is relatively from the project workspace directory.
The plugin also adds the functionality of the Script Console to the project configuration page. You can schedule your system management script...
...and then observe progress in the build log.
The plain "Groovy Script" is run in a forked JVM, on the slave where the build is run. It's the basically the same as running the "groovy" command and pass in the script.
The system groovy script, OTOH, runs inside the Jenkins master's JVM. Thus it will have access to all the internal objects of Jenkins, so you can use this to alter the state of Jenkins. It is similar to the Jenkins Script Console functionality.
System groovy jobs has access to whole Jenkins, therefore only users with admin rights can add system groovy build step and configure the system groovy script. Permissions are not checked when the build is triggered (i.e. also uses without admin rights can also run the script). The idea is to allow users run some well defined (defined by admin) system tasks when they need it (e.g. put slave offline/online, when user wants to start some debugging on slave). To have Jenkins instance secure, the support for Token macro plugin has to be switched off, see section bellow.
Groovy plugin provides support for Token Macro Plugin. Expression is GROOVY with parameter script:
By default, the support for token macro pressing is switched off and has to be switch on in global config page.
Execute a system Groovy script like:
To retrieve properties defined in the Properties field use:
Skip to end of metadata Go to start of metadata