Enable groovy scripting in Jenkins
Traditionally user create jobs in Jenkins by providing necessary build / post build actions by filling the job details manually. With introduction of Pipeline plugin, users now can now implement a project’s entire build/test/deploy pipeline in a
Jenkinsfile and store that alongside their code, treating their pipeline as another piece of code checked into source control.
pipeline plugin allows following (but not limited to) capabilities:
- the ability to suspend/resume of executing jobs.
- checking the pipeline definition into source control (
- support for extending the domain specific language with additional, organization specific steps, via the “Shared Libraries” feature.
In order to enable Groovy scripting as Jenkins job steps (via pipeline plugin), one can configure Groovy installation on jenkins system by following below steps:I
Step1: Groovy plugin
Navigate to Jenkins -> Manage Jenkins -> Configure system and install “Groovy plugin”
Step 2: Enable Groovy path
Navigate to Jenkins -> Manage -> Global Tool Configuration -> your system, go to Jenkins configuration page, find section ‘Groovy’ and fill the form as shown bellow.
Name = Groovy
check the checkbox “Install automatically”
Install from Groovy website = Select a groovy build from drop down
In order to create Groovy-based project, (by adding free-style project) one can select “Execute Groovy script” in the Build section, and allows one to execute Groovy command, or specify your script file name.
(In the second case path taken is relatively from the project workspace directory).