GoCD API - Environment Config

34 views
Skip to first unread message

Tobias Petrén

unread,
Mar 11, 2020, 4:28:50 AM3/11/20
to go-cd
Hi.

I have previously used version 19.1 of GoCD and in that version I could use the GoCD API to create an environment with pipelines and agents (see picture below).

gocdapi.PNG


I recently updated to version 20.1 of GoCD and it seems like I can no longer add agents when creating an environment config with GoCD API (see picture below).


gocdapinew.PNG


Why was this option removed and which is the best way to add agents to my environment config now?


Regards,

Tobias



kritik...@thoughtworks.com

unread,
Mar 11, 2020, 4:50:17 AM3/11/20
to go-cd
Hello Tobias,

You can find the discussion around this on: https://github.com/gocd/gocd/issues/911

To give you a brief: Agents were originally stored in the cruise-config.xml. Every time any change occurs, the whole config used to be updated. This takes up a lot of time considering bigger configs. Hence, we decided to move them to DB.

Since, environments are still stored in the config -  Addition of agent via environment API would have required a lock on both config and DB - which could have lead to all sorts of lock and rollback issues. Hence the decision to keep them separate.

From 19.9.0 onwards please use the Agents API (https://api.gocd.org/current/#agents) to update the same. You can also do via UI from Agents Page and Environments Page.

Hope this helps!

Thanks
Kritika

Tobias Petrén

unread,
Mar 11, 2020, 5:20:59 AM3/11/20
to go-cd
Hi.

Ok, then I understand why this was removed. Thanks.

I will have to change my code and use Agents API. A question about this API then, can I update an agent (for example adding environments) while that agent is building?

/Tobias

kritik...@thoughtworks.com

unread,
Mar 11, 2020, 5:33:24 AM3/11/20
to go-cd
Hi Tobias,

Yes you can update an agent's config while it is building. Any change in environment, resources would not effect the current building job. But the next job assigned to that agent will be on basis of environments, resources, etc.

Thanks

Tobias Petrén

unread,
Mar 11, 2020, 5:56:58 AM3/11/20
to go-cd
Ok, great. Thanks for helping! Then I know how to fix this with the latest version of GoCD.

/Tobias
Reply all
Reply to author
Forward
0 new messages