Create environment groups
Learn how to group environments.
Environment groups are simple a way to group environments so you can assign permissions to multiple environments in a role.
From your Project Settings, select Environments.
Select Environment Groups on the top-right corner of the page.
Select New Environment Group.

Enter a name for the environment group, and select the environments you want to add to this group. You can also select New Environment to create a new environment and add it to this group.

Click Submit.
Here is a sample environment group YAML.
Cross Scope Environment Groups
You can also add environments created at the Account and Organization levels to the Environment Group.
From your Project Settings, select Environments.
Select Environment Groups at the top-right corner of the page.
Click New Environment Group.
Enter a name for the environment group. All the environments created at the Project, Organization, and Account levels will be displayed under the respective tabs. Select the environments needed in your Environment Group and click Submit.

Once the Environment group is created, you can see all the environments along with their scopes listed.

Below is an example of the YAML for an environment group:
Under envIdentifiers,
The environments associated with the Project level do not have a prefix.
The environments associated with the Organization level are prefixed with
org.The environments associated with the Account level are prefixed with
account.
Using environment groups
Environment groups can only be used in multi environment and infrastructure based deployments. By default, Harness will loop through each environment in the environment group and deploy. You can specify whether you want to deploy to one environment or all the environments in the group.
Referencing environment groups
You can reference which environment group was selected using as an expression. It can be captured as an output from the infrastructure step in the pipeline.
Environment group name:
<+pipeline.stages.[STAGE_ID].spec.infrastructure.output.environment.envGroupName>.Environment group Id:
<+pipeline.stages.[STAGE_ID].spec.infrastructure.output.environment.envGroupRef>.
Limitations
You cannot pass environment group in the studio as an expression
Harness team is looking to solve:
How to handle infrastructures that have runtime input parameters when the expression is referenced?
How to deploy to a subset of those environments in the environment group?
How do we propagate the environment group as an expression to the following stage?
Last updated
Was this helpful?