Environments Allure 3
Allure Report 3 offers a new way to organize test results by environments, allowing you to group together tests by operating systems, browsers, deployments - or any other ways of categorization, and compare results from different environments easily.
This feature is based on test result labels: you can map certain labels (or combinations of labels) to a specific environment name, and Allure Report 3 will split all test results on the report home page into separate hierarchies, which you can switch between via the Environments dropdown menu.

Additionally, on the Environments tab of every test result you will be able to see available results of the same test from other environments.

Prerequisites
- In a static configuration file (
.json,.yaml,.yml), write the matchers as expressions instead of functions. - You should set the labels storing environment information in your tests code. Please refer to the documentation of the framework integration you're using to find out how.
Basic configuration
Environments are governed by the environments configuration parameter.
The keys of the environments object are environment IDs — short identifiers used internally (latin letters, digits, underscores, and hyphens only, up to 64 characters). Each entry requires a matcher function and also accepts an optional name field for the display name shown in the report. If name is omitted, the ID is used as the display name.
The examples below show how to assign environments based on a single label or multiple labels. Allure will look for labels named os and, in the two-label example, browser, and assign environments accordingly:
{
environments: {
windows: {
matcher: ({ labels }) =>
labels.find(({ name, value }) => name === "os" && value === "Windows"),
},
macos: {
matcher: ({ labels }) =>
labels.find(({ name, value }) => name === "os" && value === "macOS"),
},
linux: {
matcher: ({ labels }) =>
labels.find(({ name, value }) => name === "os" && value === "Linux"),
}
}
}{
environments: {
"windows-chrome": {
matcher: ({ labels }) =>
labels.some(l => l.name === "os" && l.value === "Windows") &&
labels.some(l => l.name === "browser" && l.value === "Chrome"),
},
"windows-firefox": {
matcher: ({ labels }) =>
labels.some(l => l.name === "os" && l.value === "Windows") &&
labels.some(l => l.name === "browser" && l.value === "Firefox"),
},
"ubuntu-chrome": {
matcher: ({ labels }) =>
labels.some(l => l.name === "os" && l.value === "Ubuntu") &&
labels.some(l => l.name === "browser" && l.value === "Chrome"),
},
"ubuntu-firefox": {
matcher: ({ labels }) =>
labels.some(l => l.name === "os" && l.value === "Ubuntu") &&
labels.some(l => l.name === "browser" && l.value === "Firefox"),
}
}
}The above configurations result in environment menus like these:

To set a display name that is different from the ID, add the name field:
{
environments: {
prod_env: {
name: "Production", // shown in the report; ID "prod_env" is used internally
matcher: ({ labels }) =>
labels.find(({ name, value }) => name === "env" && value === "production"),
},
}
}How matcher functions work
- Allure reads test result files and loads all
labelsfrom each test result. - The matcher function receives
{ labels: TestLabel[] }from the Allure Report process. Each label is{ name: string, value: string }. - If the test result belongs to the environment, the matcher function returns
true. - First match wins - tests results cannot be assigned to multiple environments, so the order of environments in the config file matters.
- If Allure can't match a test result to any environment, it assigns it to the
defaultenvironment, so no test results get lost. - In a YAML or JSON configuration file, a matcher is an expression that receives the same labels.
Environment variables
You can add any metadata that applies to the whole report via the global variables configuration parameter. Allure displays it at the top of the report homepage in the Variables section.
In addition to global variables, you can set environment-specific variables, which can override existing global variables, or be displayed in addition to them, when you select a specific environment:
// Global vs Environment-Specific Variables
{
variables: {
"App Version": "2.5.1", // Shown everywhere
"Build Number": "#1234", // Shown everywhere
"Database": "prod-db-primary" // Shown, unless overridden
},
environments: {
staging: {
matcher: ({ labels }) =>
labels.some(({ name, value }) => name === "env" && value === "staging"),
variables: {
"Server": "staging.example.com", // Shown for staging
"Database": "staging-db", // Overrides global variable for staging
}
},
production: {
matcher: ({ labels }) =>
labels.some(({ name, value }) => name === "env" && value === "production"),
variables: {
"Server": "api.example.com", // Shown for production
}
}
}
}
Forcing a single environment
When you don't need label-based matching and already know which environment a run belongs to, you can use the environment top-level configuration option to assign all test results to one environment ID directly, bypassing matcher logic entirely:
export default {
environment: "staging",
};This is the config-file equivalent of the --environment CLI flag described below. The CLI flag takes priority if both are set.
Restricting valid environments
The allowedEnvironments top-level configuration option lets you declare an explicit allowlist of environment IDs. Any environment ID — from the environments map, the environment override, or test result data — that is not in the list causes a validation error at startup:
export default {
allowedEnvironments: ["staging", "production", "windows", "macos"],
};Use this to catch environment misconfigurations early, especially in projects where the set of valid environments is fixed.
Environments from label values
If you don't know all environments in advance, for example, the names of the CI agents, let Allure create an environment for each value of a label with the dynamicEnvironments top-level configuration option:
export default {
dynamicEnvironments: {
label: "host",
pattern: "^[\\w-]+",
name: "Host {value}",
},
};{
"dynamicEnvironments": {
"label": "host",
"pattern": "^[\\w-]+",
"name": "Host {value}"
}
}dynamicEnvironments:
label: host
pattern: "^[\\w-]+"
name: "Host {value}"label- the label whose value becomes the environment.pattern(optional) - a regular expression. The environment is the part of the value that matches it, or its first capture group. For example,^[\w-]+turnsrunner-a.example.comintorunner-a. Test results whose label value doesn't match go to theunresolvedenvironment.name(optional) - the display name of the environments, where{value}is replaced with the environment.
Test results without the label go to the default environment. Environment IDs can contain only latin letters, digits, underscores and hyphens: Allure replaces other characters with underscores and uses the original value as the display name.
In a JavaScript configuration file, dynamicEnvironments can also be a function. It receives { labels } and returns the environment ID, an object with id and name, or undefined for the default environment:
export default {
dynamicEnvironments: ({ labels }) => labels.find(({ name }) => name === "host")?.value,
};Allure uses dynamicEnvironments only for the test results that the environment option and the matchers of environments don't assign. If an environment it creates is also listed in environments, the name from there is used. If allowedEnvironments is set, Allure leaves out the test results whose environment isn't in the list, and prints an error for each of them. With allure watch, new environments appear in the report without changing the configuration.
WARNING
Every label value becomes an environment, so use a label with few, stable values. Values such as build numbers or the names of short-lived agents create many environments, and Allure prints a warning when there are more than 50. If you change dynamicEnvironments later, tests can move to other environments, and their new results are no longer linked with the history and retries of the earlier ones.
CLI override and CI/CD workflows
Allure CLI allows you to override environment assignment for the entire test launch by using the allure run wrapper command.
Use --environment to specify the environment by its ID (the config key):
allure run --environment="<environment_id>" -- <test_command>Or use --environment-name to specify it by display name:
allure run --environment-name="<environment_display_name>" -- <test_command>--environment takes priority over --environment-name if both are provided. Both take priority over the environment value in the config file.
For example:
allure run --environment="prod_env" -- pnpm test
allure run --environment-name="Production" -- pnpm testIts main use is running tests in multiple environments in CI/CD workflows and creating combined reports with the help of the multistage builds feature:
- You run your tests in different environments and save each run as a dump archive.
- Then you collect all dump archives and build a single multistage report from them.
- Allure maps test results from all runs to their assigned to environments and you get a well-structured unified report, where you can easily see and compare how your tests perform in different contexts.
Below is a snippet from the Allure Report 3 Demo workflow on GitHub, illustrating this idea.
jobs:
test:
name: Build
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
# ...
# Test environment set up steps
# ...
- name: Test Project
# One full test run per os saved as a dump archive
run: pnpm allure run --config=./allurerc.mjs --environment="${{ matrix.os }}" --dump="allure-results-${{ matrix.os }}" -- pnpm test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v5
with:
name: allure-results-${{ matrix.os }}
path: ./allure-results-${{ matrix.os }}.zip
compression-level: 0
report:
runs-on: ubuntu-latest
needs: test
steps:
# ...
# Report generator set up steps
# ...
# Fetching the dump archive for the Ubuntu test run
- name: Download allure results from Ubuntu
uses: actions/download-artifact@v6
with:
name: allure-results-ubuntu-latest
path: ./
# Fetching the dump archive for the macOS test run
- name: Download allure results from macOS
uses: actions/download-artifact@v6
with:
name: allure-results-macos-latest
path: ./
- name: Build report
# Building the multistage report from all fetched dump archives
run: pnpm allure generate --dump="allure-results-*.zip" --output=./allure-report
# ...
# Report deployment steps
# ...TIP
While the --environment option overrides the label mapping rules in the config file, it will still pick up any variables specified for the environment matching the one you pass. This means you can define environment variables in the config even when using --environment to assign environments.
{
environments: {
staging: {
// matcher redundant when using --environment flag
variables: {
"Server": "staging.example.com",
"Database": "staging-db"
}
},
production: {
variables: {
"Server": "api.example.com",
"Database": "prod-db-primary"
}
}
}
}The old environments feature
Allure 3 still supports adding environment metadata to a report using the legacy Allure 2 method: if an environment.properties file is discovered in the results directory, Allure displays the data from it at the top of the report page in the Metadata section.

This can either complement or conflict with your environments configuration, so make sure to get rid of this file, or to harmonize it with your new environments set up - whichever suits you best.