Gradle plugin that provides support for managing applications and databases on CloudBees RUN@cloud
Groovy Shell
Pull request Compare This branch is 7 commits ahead, 3 commits behind bmuschko:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper
src
.gitignore
LICENSE.txt
README.asciidoc
RELEASE_NOTES.md
build.gradle
gradlew
gradlew.bat

README.asciidoc

Gradle CloudBees plugin

CloudBees Logo

The plugin provides support for managing applications and databases on CloudBees RUN@cloud. Under covers the plugin communicates with the CloudBees backend via the CloudBees API client.

This plugin was originally created by Benjamin Muschko as an example for the book "Gradle in Action". For more info, see Plugin History.

Usage

To use the CloudBees plugin, include in your build script:

apply plugin: 'cloudbees'

The plugin JAR needs to be defined in the classpath of your build script. It is directly available on Maven Central. Alternatively, you can download it from GitHub and deploy it to your local repository. The following code snippet shows an example on how to retrieve it from Maven Central:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-cloudbees-plugin:0.1'
    }
}

Tasks

The CloudBees plugin defines the following tasks:

Application tasks

Task name Depends on Type Description

cloudBeesAppChecksums

-

CloudBeesAppChecksums

Returns the checksums for an application.

cloudBeesAppDelete

-

CloudBeesAppDelete

Deletes an application.

cloudBeesAppDeployArchive

-

CloudBeesAppDeployArchive

Deploys a new version of an application using an archive file of specified type.

cloudBeesAppDeployEar

-

CloudBeesAppDeployEar

Deploys a new version of an application using a EAR file.

cloudBeesAppDeployWar

-

CloudBeesAppDeployWar

Deploys a new version of an application using a WAR file.

cloudBeesAppInfo

-

CloudBeesAppInfo

Returns the basic information about an application.

cloudBeesAppList

-

CloudBeesAppList

Returns the list of applications available to your account.

cloudBeesAppRestart

-

CloudBeesAppRestart

Restarts all deployed instances of an application.

cloudBeesAppStart

-

CloudBeesAppStart

Starts all deployed instances of an application.

cloudBeesAppStop

-

CloudBeesAppStop

Stops all deployed instances of an application.

cloudBeesAppTail

-

CloudBeesAppTail

Establishes a persistent connection to the application logs.

Database tasks

Task name Depends on Type Description

cloudBeesDbCreate

-

CloudBeesDbCreate

Creates a new database.

cloudBeesDbDrop

-

CloudBeesDbDrop

Drops a database.

cloudBeesDbInfo

-

CloudBeesDbInfo

Returns information about connecting to a database.

cloudBeesDbList

-

CloudBeesDbList

Returns a list of all the databases associated with your account.

Extension properties

The CloudBees plugin defines the following extension properties in the cloudBees closure:

Property name Type Default value Description

apiFormat

String

XML

The CloudBees API format.

apiVersion

String

1.0

The CloudBees API version.

apiUrl

String

https://api.cloudbees.com/api

The CloudBees API URL.

apiKey

String

value of property named cloudbees.api.key

The CloudBees API key.

apiSecret

String

value of property named cloudbees.api.secret

The CloudBees API secret.

appId

String

Not null

The application identifier on CloudBees.

dbId

String

Not null

The database identifier on CloudBees.

The CloudBeesAppDeployArchive uses the following additional properties in the cloudBees closure:

Property name Type Default value Description

archiveType

String

zip

The file type of the archive.

archiveFile

File

null

The archive file to upload (Required).

deltaDeploy

boolean

false

Whether to use delta for upload.

parameters

Map<String, String>

null

CloudBees Application and Runtime Parameters.

Note

CloudBees runtime parameters should prepend the String runtime. to the key, e.g. runtime.classpath.

Note

The deltaDeploy option is new, please let us know how it works.

Example

cloudBees {
    appId = 'gradle-in-action/to-do-app'
    dbId = 'gradle-in-action/to-do-db'
}

cloudBeesAppDeployWar.message = project.version

Example: Spring Boot

def springBootJarLauncherClassName = "org.springframework.boot.loader.JarLauncher"
def springBootJarFile = file("build/libs/gs-spring-boot-0.1.0.jar")

cloudBees {
    appId = 'gradle-in-action/to-do-app'
    dbId = 'gradle-in-action/to-do-db'
    archiveType = 'jar'
    archiveFile = springBootJarFile
    parameters = [containerType: "java", 'runtime.class': springBootJarLauncherClassName, 'runtime.classpath': '']
}

cloudBeesAppDeployArchive.message = project.version
cloudBeesAppDeployArchive.dependsOn assemble

For a working Spring Boot sample project on GitHub, see springboot-gradle-cloudbees-sample.

Setting API credentials

If you decide to use the properties cloudbees.api.key and cloudbees.api.secret to populate your API credentials it is recommended to set them in your ~/.gradle/gradle.properties file. The following code snippet shows an example:

cloudbees.api.key = yourApiKey
cloudbees.api.secret = yourApiSecret

Plugin History

This plugin was created by Benjamin Muschko for Chapter 8 of the book "Gradle in Action". To find the exact code featured in the book visit the gradle-in-action-source repository.