I am automating some logic with a groovy script and I thought I could run it periodically directly from Jenkins.
I have created a freestyle project and installed the groovy plugin to do so: Groovy.
Since I need to access internal objects of Jenkins such as credentials and managed files I am using the System Groovy Script option provided by the plugin.
This option allows for to specify a Groovy command and a Groovy script file. The Groovy command option allows to disable or enable the Sandbox while for some reasons the Groovy script file does not have such option.
My script works fine when running it with the Groovy command option but fails with the Groovy script file complaining about @Grab not being secure (I use it download some dependencies).
I really would like to use the Groovy script file option as it easily allow me to clone the repository where the script will be saved and then run the main script file. Moreover it allows for splitting the logic into different files.
I tried some hacks with the Groovy command option as well, such us running:
but apparently the workspace variable is not available in a freestyle project…