Deployment Environment Classification#
DevLake uses three regex pattern fields in per-repo scope configs to classify CI/CD pipeline runs and jobs as deployments and to assign them environment labels. These classifications feed the four DORA metrics (Deployment Frequency, Lead Time for Changes, Change Failure Rate, Mean Time to Restore).
The Three Pattern Fields#
All three fields are stored as plain strings in each plugin's scope config model and are compiled into a RegexEnricher at task-start time.
| Field | Matched Against | Effect When Matched | Effect When Empty |
|---|---|---|---|
DeploymentPattern | workflow/job name | Sets Type = DEPLOYMENT | Run/job is not a deployment |
ProductionPattern | workflow/job name or branch (runs only) | Sets Environment = PRODUCTION | All deployments get PRODUCTION |
EnvNamePattern | workflow/job name | Extracts a custom environment name | No custom name extracted |
Key default behavior: ProductionPattern uses ReturnNameIfOmittedOrMatched β if the field is empty, every deployment is automatically labeled PRODUCTION. DeploymentPattern uses ReturnNameIfMatched, so it must match explicitly for a run to be classified as a deployment.
Plugin Support#
The pattern fields are present in the scope config structs for all three major CI/CD plugins:
- GitHub β
GithubScopeConfig: all three fields (DeploymentPattern,ProductionPattern,EnvNamePattern), stored in_tool_github_scope_configs - GitLab β
GitlabScopeConfig: all three fields, stored in_tool_gitlab_scope_configs - Azure DevOps β
AzuredevopsScopeConfig:DeploymentPatternandProductionPatternonly (noEnvNamePattern), stored in_tool_azuredevops_go_scope_configs
How Patterns Are Applied at Extraction Time#
The RegexEnricher is built from the scope config during PrepareTaskData and stored on the task data object. Extractors then call it per-record:
-
GitHub workflow runs (
cicd_run_extractor.go:65-66):TypeβReturnNameIfMatched(DEPLOYMENT, run.Name)EnvironmentβReturnNameIfOmittedOrMatched(PRODUCTION, run.Name, run.HeadBranch)β branch name is also checked for environment matching
-
GitHub jobs (
cicd_job_extractor.go:87-88):TypeβReturnNameIfMatched(DEPLOYMENT, job.Name)EnvironmentβReturnNameIfOmittedOrMatched(PRODUCTION, job.Name)β name only
The difference: run-level environment classification also tests the HeadBranch (e.g., main, release/*), so you can scope production to a branch pattern without renaming your workflows.
RegexEnricher Utility#
enrich_with_regex.go is the shared helper used by all CICD extractors across plugins. It compiles patterns once per task run and exposes two key methods:
ReturnNameIfMatched(name, targets...)β returnsnameif the stored regex fornamematches any target; returns""if the pattern is absent or no target matches.ReturnNameIfOmittedOrMatched(name, targets...)β returnsnameunconditionally if no pattern is registered; otherwise falls through toReturnNameIfMatched.
Configuration Reference#
| Use Case | Recommended Setting |
|---|---|
| All pipelines are deployments | Set DeploymentPattern to .* |
| Only specific workflows are deployments | Set DeploymentPattern to e.g. (?i)deploy|release |
| All deployments are production | Leave ProductionPattern empty |
| Separate prod from staging | Set ProductionPattern to e.g. (?i)prod|main |
| Custom environment names | Set EnvNamePattern to a capturing group, e.g. env-([\w-]+) |
Full configuration checklist for enabling DORA metrics end-to-end is documented in the DORA Metrics Configuration knowledge page.
Key Source Files#
| File | Purpose |
|---|---|
github/models/scope_config.go | GithubScopeConfig β pattern field definitions |
gitlab/models/scope_config.go | GitlabScopeConfig β pattern field definitions |
azuredevops_go/models/scope_config.go | AzuredevopsScopeConfig β pattern field definitions |
helpers/pluginhelper/api/enrich_with_regex.go | Shared RegexEnricher utility |
github/tasks/cicd_run_extractor.go | Run-level deployment/environment classification |
github/tasks/cicd_job_extractor.go | Job-level deployment/environment classification |