jenkins the definitive guide

(Jeff_L) #1

5.10.2.1. The Gradle plugin for Jenkins


You can install the Gradle plugin in the usual way—just go to the Manage Plugins screen and select the
Jenkins Gradle plugin. Click Install and restart your Jenkins instance.


Once Jenkins has restarted, you will need to configure your new Gradle plugin. You should now find a
new Gradle section in your Configure System screen. Here you will need to add the Gradle installation
you want to use. The process is similar to that used for the other tool installations. First, click the
Add Gradle button to add a new Gradle installation, and enter an appropriate name (see Figure 5.51,
“Configuring the Gradle plugin”). If Gradle has already been installed on your build server, you can
point to the local Gradle home directory. Alternatively, you can use the “Install automatically” feature
to download a Gradle installation, in the form of a ZIP or GZipped TAR file, directly from a URL. You
can use a public URL (see http://gradle.org/downloads.html),,) or may prefer to make these installations
available on a local server instead.


Figure 5.51. Configuring the Gradle plugin


You typically use Freestyle build jobs to configure your Gradle builds. When you add a build step to a
Freestyle build job, you will now have a new option called “Invoke Gradle script”, which lets you add
Gradle specific settings to your build job.


As an example, here is a very simple Gradle build script. It is a simple Java project that uses a
Maven directory structure and a Maven repository manager. There is a customizable task, called
uploadArchives, to deploy the generated archive to the local Enterprise repository manager:


apply plugin:'java'
apply plugin:'maven'

version='1.0-SNAPSHOT'
group = "org.acme"

repositories{
mavenCentral()
mavenRepo urls: 'http://build.server/nexus/content/repositories/public'
}
Free download pdf