Skip to content

getsentry/gocd-jsonnet-config-plugin

 
 

Join the chat at https://gitter.im/gocd/gocd

gocd-jsonnet-config-plugin

GoCD plugin to keep pipelines and environments configuration in source-control in Jsonnet. See this document to find out what are GoCD configuration repositories.

This is the third GoCD configuration plugin, which builds off of the YAML configuration plugin

  • Format is extensible - you can use libraries and functions to build your configuration
  • Format is concise - you can use variables, functions, and imports to keep your configuration DRY
  • Format is powerful - you can use conditionals, comprehensions, and other language features to build your configuration

Table of contents

  1. Setup
  2. File pattern
  3. Overview
  4. Development

Setup

Step 1: You need to install the plugin in the GoCD server. Download it from the releases page and place it on the GoCD server in plugins/external directory.

Step 2: Follow the GoCD documentation to add a new configuration repository.

You can use the example repository at: https://github.com/getsentry/gocd-jsonnet-config-example.git.

File pattern

The default pattern is **/*.jsonnet,**/jsonnetfile.json, which will recursively search the entire repository for all files ending with .jsonnet and files named jsonnetfile.json. While jsonnetfile.json is not a valid jsonnet file, it is used to specify dependencies for the jsonnet files. See jsonnet-bundler for more information. If there are no external dependencies, you can omit the jsonnetfile.json file.

You can set a custom file pattern per configuration repository using the GoCD configuration UI: jsonnet pattern config

Or in the config XML using <configuration>:

<config-repos>
  <config-repo pluginId="jsonnet.config.plugin" id="repo1">
    <git url="https://github.com/getsentry/gocd-jsonnet-config-plugin.git" />
    <configuration>
      <property>
        <key>file_pattern</key>
        <!-- comma-separate multiple patterns -->
        <value>pipelines/build/*.jsonnet,pipelines/lint/*.jsonnet</value>
      </property>
    </configuration>
  </config-repo>
</config-repos>

Overview

Please note this brief overview of what is done by the plugin:

  • parsing jsonnet into json when GoCD server asks for it.

And this is done by the GoCD server:

  • complex logic merging multiple config repo sources and XML
  • validation of pipelines/stages/jobs/tasks domain
  • any UI rendering

Development

Environment setup

To build and test this plugin, you'll need java jdk >= 11.

If you have local java environment, then you may run all tests and create a ready to use jar with:

./gradlew test jar

Versioning

We use semantic versioning.

About

Plugin to declare GoCD pipelines and environments configuration in Jsonnet

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 86.3%
  • Jsonnet 6.3%
  • Shell 5.7%
  • Groovy 1.3%
  • HTML 0.4%