Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Groovy Java

This branch is 231 commits ahead of abayer:master

Merge pull request #56 from daspilker/JENKINS-29297

[JENKINS-29297] allow to override system properties
latest commit 913fd38c73
@daspilker daspilker authored

Gradle JPI plugin

This is a Gradle plugin for building Jenkins plugins, written in Groovy or Java.


Add the following to your build.gradle:

buildscript {
    repositories {
        // The plugin is currently only available via the Jenkins
        // Maven repository, but has dependencies in Maven Central.
        maven {
            url ''
    dependencies {
        classpath ''

apply plugin: 'org.jenkins-ci.jpi'

group = 'org.jenkins-ci.plugins'
version = '1.2.0-SNAPSHOT'
description = 'A description of your plugin'

jenkinsPlugin {
    // version of Jenkins core this plugin depends on, must be 1.420 or later
    coreVersion = '1.420'

    // short name of the plugin, defaults to the project name without trailing '-plugin'
    shortName = 'hello-world'

    // human-readable name of plugin                                               
    displayName = 'Hello World plugin built with Gradle'

    // URL for plugin on Jenkins wiki or elsewhere
    url = ''

    // plugin URL on GitHub, optional
    gitHubUrl = ''              

    // use the plugin class loader before the core class loader, defaults to false
    pluginFirstClassLoader = true

    // optional list of package prefixes that your plugin doesn't want to see from core 
    maskClasses = 'groovy.grape org.apache.commons.codec'

    // optional version number from which this plugin release is configuration-compatible
    compatibleSinceVersion = '1.1.0'

    // set the directory from which the development server will run, defaults to 'work'
    workDir = file('/tmp/jenkins')

    // URL used to deploy the plugin, defaults to the value shown
    repoUrl = ''

    // URL used to deploy snapshots of the plugin, defaults to the value shown
    snapshotRepoUrl = ''

    // enable injection of additional tests for checking the syntax of Jelly and other things
    disabledTestInjection = false

    // the output directory for the localizer task relative to the project root, defaults to the value shown
    localizerOutputDir = "${project.buildDir}/generated-src/localizer"

    // disable configuration of Maven Central, the local Maven cache and the Jenkins Maven repository, defaults to true
    configureRepositories = false

    // skip configuration of publications and repositories for the Maven Publishing plugin, defaults to true
    configurePublishing = false

    // plugin file extension, either 'jpi' or 'hpi', defaults to 'hpi'
    fileExtension = 'hpi'

    // the developers section is optional, and corresponds to the POM developers section
    developers {
        developer {
            id 'abayer'
            name 'Andrew Bayer'
            email ''

Be sure to add the jenkinsPlugin { ... } section before any additional repositories are defined in your build.gradle.

Dependencies on other Jenkins Plugins

If your plugin depends on other Jenkins plugins you can specify the dependencies in the following way:

dependencies {
    jenkinsPlugins 'org.jenkinsci.plugins:git:1.1.15@jar'
    optionalJenkinsPlugins 'org.jenkins-ci.plugins:ant:1.2@jar'
    jenkinsTest 'org.jenkins-ci.main:maven-plugin:1.480@jar'

Adding the dependency to the jenkinsPlugins configuration will make all classes available during compilation and also add the dependency to the manifest of your plugin. To define an optional dependency on a plugin then use the optionalJenkinsPlugins configuration and to use a plugin only for testing, add a dependency to the jenkinsTest configuration.

Note that you must use the artifact only notation (append @jar if you're using the semicolon notation as in the example or specify ext: 'jar' if you're using the map-style notation).


  • gradle jpi - Build the Jenkins plugin file, which can then be found in the build directory. The file will currently end in ".hpi".
  • gradle publishToMavenLocal - Build the Jenkins plugin and install it into your local Maven repository.
  • gradle publish - Deploy your plugin to the Jenkins Maven repository to be included in the Update Center.
  • gradle server - Start a local instance of Jenkins (http://localhost:8080) with the plugin pre-installed for testing and debugging.


It is possible to attach a remote debugger to the Jenkins instance started by gradle server. The GRADLE_OPTS environment variable must be used to configure the JVM debug options.

$ export GRADLE_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
$ ./gradlew server

The server task enables several debug options: stapler.trace, stapler.jelly.noCache and debug.YUI. This increases the page load time. All option can be changed and new options can be added by passing them as system properties to the Gradle command line.

$ ./gradlew -Dstapler.jelly.noCache=false server


Here are some real world examples of Jenkins plugins using the Gradle JPI plugin:

Something went wrong with that request. Please try again.