Plugin to declare GoCD pipelines and environments configuration using a Groovy DSL
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
dsl Merge pull request #9 from ketan/dependabot/gradle/org.junit.jupiter-… Dec 6, 2018
gocd-groovy-dsl-config-plugin Merge pull request #9 from ketan/dependabot/gradle/org.junit.jupiter-… Dec 6, 2018
gradle/wrapper Upgrade gradle. Dec 6, 2018
jar-class-loader/src/main/java/com/thoughtworks/gocd Initial commit Aug 7, 2018
sandbox Bump commons-lang3 from 3.7 to 3.8.1 Dec 6, 2018
LICENSE Initial commit Aug 7, 2018 Initial commit Aug 7, 2018
build.gocd.groovy Fix typo Sep 23, 2018
build.gradle Bump release Dec 7, 2018
gradlew Initial commit Aug 7, 2018
gradlew.bat Initial commit Aug 7, 2018
plugin-common.gradle Initial commit Aug 7, 2018
settings.gradle Initial commit Aug 7, 2018

Join the chat at

GoCD Groovy DSL Configuration Plugin

A GoCD plugin that allows maintaining pipelines and environments in source control using a DSL written in the groovy language.

Table of Contents

A note about security

This plugin evaluates untrusted code, on the GoCD server. A malicious script can do significant damage (steal keys and secrets, remove files and directories, install malware, etc). Since evaluating the groovy code in a sandbox is currently a work in progress, please use this plugin only with GoCD servers and repositories where you completely trust your users.


  • Download the plugin jar from the downloads page and place the jar file on the GoCD server in plugins/external directory.

  • Add config-repos element right above first <pipelines />. Then you can add any number of repository configuration repositories as such:

      <config-repo pluginId="cd.go.contrib.plugins.configrepo.groovy" id="my-project">
        <git url="" />
  • The plugin will now scan and read files ending with the extension .gocd.groovy and setup pipelines defined in those files.

Linting or verifying your DSL locally

There is some basic standalone linting abilities provided by the plugin:

java -jar groovy-dsl-plugin.jar --files file1,file2

Lint and validation of Groovy DSL

$ java -jar groovy-dsl-plugin.jar
The following option is required: [--files | -f]
Usage: java -jar groovy-dsl-plugin.jar [options]
  * --files, -f
      comma-separated list of files to verify
    --help, -h
      print this help
    --json, -j
      show generated json for the config
      Default: false

Auto complete in your IDE

If you're using an IDE like IntelliJ or Eclipse, you can import the dsl.jar file from the downloads page, or using the following maven co-ordinates in your build script:

<!-- maven -->
// gradle
compileOnly group: 'com.github.ketan', name: 'dsl', version: '0.1.0-1'


Here is a simple example of the DSL, there are mode examples in the examples directory.

import cd.go.contrib.plugins.configrepo.groovy.dsl.*

GoCD.script {
  pipelines {
    pipeline('build') {
      group = 'go-cd'
      lockBehavior = 'lockOnFailure'
      trackingTool {
        link = '${ID}'
        regex = ~/##(\d+)/

      environmentVariables = [
        'pipeline-var': 'pipeline-value'

      materials {
        git('my-repo') {
          url = ''
          branch = 'master'
          blacklist = ['', "examples/**/*"]

      stages {
        stage('test') {
          environmentVariables = [
            'stage-var': 'stage-value'
          jobs {
            job('build') {
              tasks {
                bash {
                  commandString = "git clean -fdx"

                bash {
                  commandString = './gradlew clean assemble test'


Copyright 2018, ThoughtWorks, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.