Create environment groups
Group environments so you can assign role permissions across multiple environments at once
Environment groups let you group environments so you can assign permissions to multiple environments in a role. You can also use environment groups in multi-environment and infrastructure deployments.
What you will learn from this topic
How to create an environment group and add environments to it
How to add cross-scope environments from the project, organization, and account levels
How to use environment groups in multi-environment deployments
How to reference environment group expressions in a pipeline
Understand the limitations that apply when you plan environment group usage
Before you begin
Before you begin, make sure you have the following:
Environments: Create at least one environment before you build a group. Go to Create environments to create environments.
Permissions: You need permission to view and manage environments at the scope where you create the group. Go to the permissions reference to review environment permissions.
Create an environment group
Perform the following steps to create an environment group and add environments to it:
The following sample shows environment group YAML:
Create a cross-scope environment group
With the cross-scope feature enabled, you can add environments from the project, organization, and account levels to one environment group. Perform the following steps to create a cross-scope 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. Environments created at the Project, Organization, and Account levels appear under the respective tabs. Select the environments you need, then click Submit.

After the environment group is created, you can see all environments and their scopes listed.

The following example shows YAML for a cross-scope environment group:
Under envIdentifiers, the prefixes work as follows:
Environments associated with the Project level have no prefix.
Environments associated with the Organization level are prefixed with
org.Environments associated with the Account level are prefixed with
account.
Use environment groups
Environment groups can only be used in multi-environment and infrastructure based deployments. By default, Harness loops through each environment in the environment group and deploys. You can specify whether you want to deploy to one environment or all the environments in the group.
Reference environment groups
You can reference which environment group was selected by using expressions. Capture the values as output from the infrastructure step in the pipeline. The following expressions are available:
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
The following limitations apply when you work with environment groups:
You cannot pass an environment group in Pipeline Studio as an expression.
Open product questions for expression-based usage include:
How to handle infrastructures that have runtime input parameters when the expression is referenced
How to deploy to a subset of the environments in the environment group
How to propagate the environment group as an expression to the following stage
Next steps
Create environments: Create the environments you add to a group.
Environment overview: Review how environments and infrastructure definitions fit Continuous Delivery pipelines.
Service overrides: Override service settings per environment after you group targets.
Last updated
Was this helpful?

