For the complete documentation index, see llms.txt. This page is also available as Markdown.
BETA

Create environment groups

Group environments so you can assign role permissions across multiple environments at once

This feature is in Beta and requires enablement. View all early access features.

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

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:

1

Open environment groups

Go to Project Settings -> Environments, then select Environment Groups in the top-right corner of the page.

2

Create the group

Select New Environment Group.

3

Name the group and select environments

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

Environment scope

By default, you can only add environments in the same scope (Harness project, organization, or account) as the environment group. For example, if the environment group is configured at the project level, only project-level environments can be added.

With the cross-scope feature enabled, you can also add environments created at the account and organization levels. Go to Create a cross-scope environment group for details.

Create environment groups dialog
Environment group with selected environments
4

Submit the group

Click Submit.

The following sample shows environment group YAML:

Sample 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:

  1. From your Project Settings, select Environments.

  2. Select Environment Groups at the top-right corner of the page.

  3. Click New Environment Group.

  4. 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.

Cross scope environment groups selection

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

Cross scope environment groups list

The following example shows YAML for a cross-scope environment group:

Cross-scope environment group YAML

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

Last updated

Was this helpful?