skip to content

In a GitLab CI job's `environment:` configuration, what does `deployment_tier` tell GitLab that the environment's name does not?

level: middleimportance: nice to knowfreq 22%

answer

  1. classification, not behaviour
  2. GitLab otherwise guesses from the name
  3. production, staging, testing, development, other
  4. DORA counts production deployments
  5. applies on the next deployment

basics

~20 s

deployment_tier classifies an environment as production, staging, testing, development or other, independently of what it is called. GitLab otherwise guesses the tier from the name, so an unconventionally named environment is miscounted in reporting such as DORA deployment metrics.

solid answer

~40 s

GitLab needs to know which of your environments is production-like, because features such as DORA deployment-frequency and lead-time metrics only count deployments to production tiers. By default it infers that from the environment's *name*, matching conventional words. That inference is fine for `production` and `staging`, and wrong the moment your team calls the live environment `live`, `prd`, `blue`, or a customer's name. `environment:deployment_tier` states the classification explicitly — one of `production`, `staging`, `testing`, `development` or `other` — so the naming convention and the semantics stop being coupled. It changes nothing about how the job deploys; it is purely how GitLab classifies the environment for reporting and for features that ask "is this production?". Worth noting it is applied on the next deployment, so an existing mis-tiered environment updates when the job runs again.

go deeper

for a junior

Know that deployment_tier labels an environment as production, staging, testing, development or other, and that GitLab guesses from the name when you leave it out.

for a middle

Explain why the guess matters: DORA and value-stream reporting count production-tier deployments, so an environment called live or prd is silently excluded until you declare the tier.

for a senior

Apply it where naming is not standard — per-region or per-tenant production environments, and production-shaped pre-production environments that would otherwise inflate deployment counts.

for a principal

Set the convention centrally so delivery metrics across many projects are comparable, and keep tier separate in your head from protected environments, which is where deployment authority actually lives.

## The problem it solves GitLab has features that need to distinguish a production deployment from a scratch one: DORA metrics such as deployment frequency and lead time for changes count deployments to production-tier environments, value-stream reporting does something similar, and the UI presents production environments differently. The only signal GitLab has by default is the environment's **name**. It matches conventional words — a name containing `production` or `prod` reads as the production tier, `staging` or `stage` as staging, `test` as testing, `dev` and `review/*`-style names as development. That heuristic is right often enough that most teams never think about it. It breaks the moment your naming does not use those words. Environments called `live`, `prd`, `blue`, `green`, `eu-1` or `acme-corp` are not recognised as production, so every real production deployment is missing from the metrics and the dashboards quietly under-report. Nothing errors; the numbers are just wrong. ## The keyword ```yaml deploy_live: stage: deploy script: ./deploy.sh live environment: name: live url: https://app.example.com deployment_tier: production ``` `deployment_tier` takes one of a fixed set of values: `production`, `staging`, `testing`, `development`, and `other`. It declares the classification rather than letting GitLab guess it. Two things it does **not** do. It does not change how or where the job deploys — the script is unaffected, and nothing about credentials, permissions or ordering follows from the tier. And it is not the mechanism that restricts who may deploy: that is protected environments, configured in project settings and keyed on the environment *name*, not the tier. The tier is recorded with the environment when a deployment runs, so setting or changing it takes effect on the next deployment to that environment rather than retroactively. ## When you actually reach for it Three situations, in practice. **Non-standard production naming.** The most common one, described above: any live environment not called some variant of "production". **Multiple production environments.** A team deploying per region or per tenant — `eu-prod`, `us-prod`, `acme`, `globex` — wants all of them counted as production. Marking each one explicitly makes the reporting correct without forcing a rename that breaks scripts and dashboards. **Environments that look production-like but are not.** A performance or pre-production environment called `prod-mirror` or `prod-shadow` will be inferred as production and inflate deployment-frequency numbers with deploys nobody shipped to customers. Tagging it `testing` or `other` keeps the metric honest. ## Naming still matters Setting the tier does not make naming irrelevant. Names are what protected-environment rules match, what environment-scoped CI/CD variables match, and what humans read on the Environments page. A consistent naming scheme plus an explicit tier is the combination that behaves well; an explicit tier bolted onto chaotic names fixes the metrics and leaves everything else hard to reason about. ## Interview framing This is a small keyword and interviewers use it as a depth probe rather than a gate: knowing it signals that you have actually looked at what GitLab does with environment records beyond "it shows a link". The answer worth giving is one sentence of mechanism — it declares the classification GitLab would otherwise infer from the name — plus the reason it matters, which is that deployment metrics silently count the wrong things when the inference is wrong.

  • An environment named `live` shows no deployments in GitLab's deployment-frequency metric. What is the likely cause?
    GitLab infers the tier from the name and `live` matches nothing it recognises as production, so those deployments are classified as another tier and excluded from the production-only metric. Setting `deployment_tier: production` on the job's environment block fixes it from the next deployment onward.
  • Does `deployment_tier: production` restrict who can deploy to that environment?
    No. The tier is a classification used for reporting and presentation. Restricting deployments is the job of protected environments, configured in the project's CI/CD settings and matched on the environment name, with allowed-to-deploy roles and optional approval rules.

saying these in an interview costs you the question

  • Thinks the tier controls permissions or approvals
  • Believes the tier changes how the job deploys
  • Assumes GitLab always knows which environment is production
  • Sets the tier and expects existing history to be reclassified

context