Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 3.6 KB

README.md

File metadata and controls

79 lines (57 loc) · 3.6 KB

Buildkite Gradle Plugin

Build Status GitHub tag (latest SemVer)

A Gradle plugin that provides a DSL for dynamically generating Buildkite pipelines.

Made with ❤️ by Widen.

Installation

First add the plugin to your project:

plugins {
    id 'com.widen.buildkite' version '0.5.1'
}

Check out the releases page for a list of versions and the changelog for each. Now you are ready to start defining Buildkite pipelines using Groovy inside your build.gradle!

Configuration

Below is an example of defining a Buildkite pipeline:

buildkite {
    pipeline('deployStage') {
        def regions = ['us-east-1', 'eu-west-1']

        regions.each { region ->
            commandStep {
                label ":rocket: Deploy app to stage $region"
                command "./bksh deploy-helm-2 -r app-stage -f app-stage-${region}.yaml -g \${DOCKER_TAG} -k k8s2-stage-$region -v 4.2.3"
                agentQueue 'deploy-stage', region
            }
            commandStep {
                label ":sleeping: Wait for stage $region deploy to finish"
                command "./bksh wait-for-deploy http://app.${region}.widen-stage.com/health"
                agentQueue 'deploy-stage', region
            }
        }

        waitStep()

        regions.each { region ->
            commandStep {
                label ":smoking: Integration test the stage $region deployment"
                command "./gradlew app-app:integrationTest -Dapp.endpoint=http://app.${region}.widen-stage.com --continue \${GRADLE_SWITCHES}"
                branch 'master'
                agentQueue 'integ-stage', region
                dockerCompose {
                    run 'gradle'
                }
            }
        }
    }
}

A Gradle task named uploadDeployStagePipeline will be created automatically. Running this Gradle task locally spits out the JSON representation, so you can see if your pipeline looks correct. Inside Buildkite the pipeline will be added to the current build.

You can also define your pipelines inside Gradle files in a .buildkite directory matching the pattern pipeline*.gradle. These files will be loaded and evaluated inside the pipeline context automatically (unless buildkite.includeScripts is set to false). The name of the pipeline is determined from the file name automatically; pipeline.{name}.gradle becomes the camelCase version of {name}, while pipeline.gradle is named default. See pipeline.extra-steps.gradle for an example of this.

This example demonstrates the power of using a language like Groovy to dynamically generate a pipeline based on lists or other dynamic code. You could even parallelize your unit tests by generating a separate step for each subproject reported by Gradle! Check out the plugin's own pipeline for more examples.

Tasks

Aside from the upload{name}Pipeline tasks created, a pipelines task is also provided that lists the names of all pipelines found in the project.

License

Available under the Apache-2.0 license. See the license file for details.