Home

Awesome

gradle-stash-plugin

Support Status Gradle Plugin Portal Maven Central Apache 2.0

This plugin is no longer supported.

A plugin to run Stash SCM tasks.

Most of the tasks are run against the Stash REST API, but some of them also require running git commands in the command line.

Usage

Provided plugins

The JAR file comes with two plugins:

<table> <tr> <th>Plugin Identifier</th> <th>Depends On</th> <th>Type</th> <th>Description</th> </tr> <tr> <td>gradle-stash-base</td> <td>-</td> <td>StashBasePlugin</td> <td>Provides Stash custom task types and exposes extension for configuration.</td> </tr> <tr> <td>gradle-stash</td> <td>gradle-stash-base</td> <td>StashPlugin</td> <td>Provides a set of default Stash tasks.</td> </tr> </table>

The gradle-stash plugin helps you get started quickly. To use the Stash plugin, include the following code snippet in your build script:

apply plugin: 'com.netflix.nebula.gradle-stash'

If you need full control over the creation of your tasks, you will want to use the gradle-stash-base plugin. The downside is that each task has to be configured individually in your build script. To use the Stash base plugin, include the following code snippet in your build script:

apply plugin: 'com.netflix.nebula.gradle-stash-base'

Tasks provided by gradle-stash

Extension properties

The plugin exposes an extension with the following properties:

Example

It's recommended to not hardcode credentials in your build.gradle file.

stash {
    stashRepo = 'example-repo'
    stashProject = 'example-project'
    stashHost = 'my-host'
    stashUser = 'foo'
}

Setting extension and task properties

Most of the tasks provided by the gradle-stash plugin do not provide sensible defaults for their input properties. It's up to the plugin user to provide and assign values. If you want to conveniently set properties without having to change your build script, please have a look at the gradle-override-plugin.

If you are transitioning from a previous version of the plugin, there a various ways to set properties. Here're some options including an example that demonstrates the use case:

Using project properties

On the command line provide a project project via -PtargetBranch=master.

In your build script, parse the provided project property and assign it to the task property:

mergeBuiltPullRequests.targetBranch = project.hasProperty('targetBranch') ? project.getProperty('targetBranch') : null

Using system properties

On the command line provide the a project project via -Dtarget.branch=master.

In your build script, parse the provided system property and assign it to the task property:

mergeBuiltPullRequests.targetBranch = System.getProperty('target.branch')

Using the override plugin

On the command line provide the path to your project as system property with the prefix override. e.g. -Doverride.mergeBuiltPullRequests.targetBranch=master. There's not need to change the build script. The override plugin takes care of resolving the specific property, converting the value to the correct data type and assigning the value.