Pipelines as code
    Your query search resulted in no results.

    Pipelines as code

    GoCD supports storing pipeline configuration in a source code repository, either with your application code or in a separate repository all on its own. It allows you to move it out of GoCD so that you can modify, control and version it externally. Such modifications will be seen by a periodic poller in the GoCD server and it will merge those pipeline configurations into the pipelines it finds in the main configuration XML file. You can see a quick preview video of this feature here.

    It is important to note that not all pipelines need to be external to the config (any existing config, in any existing GoCD server will be valid). It is also important to note that this feature includes the ability for GoCD to monitor and merge external pipelines defined in multiple “config repositories”. It is also possible for a pipeline defined in a config repository to be dependent on a pipeline defined in the main config XML of the GoCD server.

    This ability is exposed as a plugin endpoint and so, anyone can write a plugin for a config repository, to store the configuration in any manner you choose.

    Here’s an image which shows the relationship between the different pieces of a setup such as this:

    Pipelines as code

    A quick note about “Infrastructure as code”: Many people seem to associate only being able to check in configuration to a repository as a part of “Infrastructure as code”. However, the ability to configure the GoCD server through code has existed in various forms. For instance, gomatic, using GoCD APIs, yagocd, gocd-cli, etc. This is another way of doing the same. In this case, it’s possible to make it more declarative, depending on the plugin and possibly give more control to others.

    Currently available plugins for storing pipelines as code

    Pipelines can currently be stored using JSON or YAML. Please refer to JSON file configuration and YAML file configuration for more information about the format of the files.

    The config repositories page (Admin -> Config Repositories) lists existing config repos and allows CRUD (Create-Read-Update-Delete) operations for a config repo. This page also show errors and allows users to force a check of the repository.

    Pipelines as code page

    Storing pipeline configuration in JSON

    The setup needed to tell GoCD where to find the pipeline configuration files is:

    • After starting the server, goto “Admin -> Config repositories”.

    Config repositories

    • Click on the “Add” button available on the top right corner and select “JSON configuration Plugin” as plugin ID.

    Config repo json

    Once you add the config repository, you should see new pipelines on the pipeline dashboard. If there are any errors, you should see it on this page.

    Storing pipeline configuration in YAML

    The setup needed to tell GoCD where to find the pipeline configuration files is:

    • After starting the server, goto “Admin -> Config repositories”.

    Config repositories

    • Click on the “Add” button available on the top right corner and select “YAML configuration Plugin” as plugin ID.

    Config repo yaml

    Once you add the config repository, you should see new pipelines on the pipeline dashboard. If there are any errors, you should see it on this page.

    Pipeline export feature

    In GoCD release 19.1.0, we introduced ability to export pipeline to a format which can be used by the config repository plugins (for instance, YAML or JSON plugins). Users can later check in these pipeline definitions to a repository and remove them from GoCD’s config.

    Config repo yaml