GoCD pipelines as a config repository

17 views
Skip to first unread message

SHWETHA H R

unread,
Jan 9, 2025, 1:33:59 AMJan 9
to go-cd
Hello,

We have GoCD pipelines configured in our current set up and we want to move these pipeline json configuration files to BitBucket and set up a config repository and import these pipelines in the new GoCD.

We have used GoCD API to export these pipelines. But the pipeline json configuration looks different from the manually download one.

The one that is downloaded from the UI works fine with the config repository, but the API one is not working. I see there is an attribute parameter being used within the materials and it is not there in the manually downloaded one. This is causing the issue.

"materials": [
          {
            "attributes": {
                "url": "<repo_url>",
                "branch": "master",
                "shallow_clone": false,
                "filter": {
                  "ignore": [],
                  "includes": []
                },
                "auto_update": true
            },
            "type": "git"
          }
    ]

We are following https://api.gocd.org/24.1.0/#get-pipeline-config to fetch the pipeline config.

It is difficult to download so many pipelines manually and make changes in each and every pipeline.
Please let us know if there is any change that we need to make in the API call to export it without the attributes parameter or please share the API document that supports config repository. 

Thanks and Regards,
Shwetha

Chad Wilson

unread,
Jan 9, 2025, 1:45:54 AMJan 9
to go...@googlegroups.com
Hi Shwetha

If you want to get your pipelines into config repositories, the right API to use is the export API: https://api.gocd.org/current/#export-pipeline-config-to-config-repo-format i.e
/go/api/admin/export/pipelines/<pipelineName>?plugin_id=json.config.plugin
The "raw" JSON API format of GoCD pipelines you refer to below predates configuration repositories and the format differs, as you've observed. The export API delegates to the individual plugin type to determine what a given pipeline looks like in its own format.

This API is the equivalent to using the download/export button for an individual pipeline from the UI:

image.png

-Chad

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/go-cd/2a76b98f-86c1-48bc-9101-47a1ee021100n%40googlegroups.com.

SHWETHA H R

unread,
Jan 9, 2025, 2:52:13 AMJan 9
to go-cd
Hi Chad,

This works. Thank you.

Regards,
Shwetha

Reply all
Reply to author
Forward
0 new messages