GoCD Environments

16 views
Skip to first unread message

Yuri Lukyanov

unread,
Mar 6, 2020, 7:08:59 AM3/6/20
to go-cd
Hello!

I've been using GoCD for quite a while but still didn't get the concept of Environments in full.

I can't think of a real use case that would be beneficial using environments.

The first thing that comes to my mind when I hear "environments" is the words "production" and "staging".
Are the environments in GoCD of the same level?

Let's say I have the "build" pipeline (1), the "deploy to staging" pipeline (2) and the "deploy to production" pipeline (3).
And there are two agents
(a) building agent
(b) a control node for deployments (for both, production and staging)

I can just assign resources to the agents.

Why would I need environments? I'm not telling they are not needed, I'm just trying to understand potential use cases.

One small benefit I see when grouping pipelines by environments is having the ability to specify a different set of environment variables,
say for (2) and (3). But those are different pipelines anyway, I can just use slightly different commands in them, just like parameters in tasks.

Maybe I'm completely missing something here. Could you share some of your use cases?

Aravind SV

unread,
Mar 9, 2020, 4:18:49 AM3/9/20
to go...@googlegroups.com
Hello Yuri,

Yes, it's a fair question. I see it as just a way of isolating agents and pipelines as mentioned here: https://docs.gocd.org/current/introduction/concepts_in_go.html#environment. There are subtle differences between using environments and just using resources, but they can be mitigated by using resources properly. For instance:

1. If you add a new job to the "deploy to production" pipeline and forget to set the right resources, then any agent (even the "building agent" in your example) can pick up that job.

2. Resources need to be managed at the job level, whereas an environment works at a higher level, essentially being a default "resource" at the pipeline level.

However, with careful use of resources, you should be able to easily reproduce similar effects, without using environments, as you said.

Cheers,
Aravind
Reply all
Reply to author
Forward
0 new messages