Commit 528e3b2d authored by Fabian Schneider's avatar Fabian Schneider Committed by Mayra Cabrera

Add deployment tier to predefined CI env variables [RUN ALL RSPEC] [RUN AS-IF-FOSS]

parent 0aa318a1
...@@ -223,6 +223,7 @@ class Environment < ApplicationRecord ...@@ -223,6 +223,7 @@ class Environment < ApplicationRecord
Gitlab::Ci::Variables::Collection.new Gitlab::Ci::Variables::Collection.new
.append(key: 'CI_ENVIRONMENT_NAME', value: name) .append(key: 'CI_ENVIRONMENT_NAME', value: name)
.append(key: 'CI_ENVIRONMENT_SLUG', value: slug) .append(key: 'CI_ENVIRONMENT_SLUG', value: slug)
.append(key: 'CI_ENVIRONMENT_TIER', value: tier)
end end
def recently_updated_on_branch?(ref) def recently_updated_on_branch?(ref)
......
...@@ -53,6 +53,7 @@ There are also [Kubernetes-specific deployment variables](../../user/project/clu ...@@ -53,6 +53,7 @@ There are also [Kubernetes-specific deployment variables](../../user/project/clu
| `CI_ENVIRONMENT_SLUG` | 8.15 | all | The simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, and so on. Available if [`environment:name`](../yaml/README.md#environmentname) is set. The slug is [truncated to 24 characters](https://gitlab.com/gitlab-org/gitlab/-/issues/20941). | | `CI_ENVIRONMENT_SLUG` | 8.15 | all | The simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, and so on. Available if [`environment:name`](../yaml/README.md#environmentname) is set. The slug is [truncated to 24 characters](https://gitlab.com/gitlab-org/gitlab/-/issues/20941). |
| `CI_ENVIRONMENT_URL` | 9.3 | all | The URL of the environment for this job. Available if [`environment:url`](../yaml/README.md#environmenturl) is set. | | `CI_ENVIRONMENT_URL` | 9.3 | all | The URL of the environment for this job. Available if [`environment:url`](../yaml/README.md#environmenturl) is set. |
| `CI_ENVIRONMENT_ACTION` | 13.11 | all | The action annotation specified for this job's environment. Available if [`environment:action`](../yaml/README.md#environmentaction) is set. Can be `start`, `prepare`, or `stop`. | | `CI_ENVIRONMENT_ACTION` | 13.11 | all | The action annotation specified for this job's environment. Available if [`environment:action`](../yaml/README.md#environmentaction) is set. Can be `start`, `prepare`, or `stop`. |
| `CI_ENVIRONMENT_TIER` | 14.0 | all | The [deployment tier of the environment](../environments/index.md#deployment-tier-of-environments) for this job. |
| `CI_HAS_OPEN_REQUIREMENTS` | 13.1 | all | Only available if the pipeline's project has an open [requirement](../../user/project/requirements/index.md). `true` when available. | | `CI_HAS_OPEN_REQUIREMENTS` | 13.1 | all | Only available if the pipeline's project has an open [requirement](../../user/project/requirements/index.md). `true` when available. |
| `CI_JOB_ID` | 9.0 | all | The internal ID of the job, unique across all jobs in the GitLab instance. | | `CI_JOB_ID` | 9.0 | all | The internal ID of the job, unique across all jobs in the GitLab instance. |
| `CI_JOB_IMAGE` | 12.9 | 12.9 | The name of the Docker image running the job. | | `CI_JOB_IMAGE` | 12.9 | 12.9 | The name of the Docker image running the job. |
......
...@@ -2720,7 +2720,7 @@ RSpec.describe Ci::Build do ...@@ -2720,7 +2720,7 @@ RSpec.describe Ci::Build do
let(:expected_variables) do let(:expected_variables) do
predefined_variables.map { |variable| variable.fetch(:key) } + predefined_variables.map { |variable| variable.fetch(:key) } +
%w[YAML_VARIABLE CI_ENVIRONMENT_NAME CI_ENVIRONMENT_SLUG %w[YAML_VARIABLE CI_ENVIRONMENT_NAME CI_ENVIRONMENT_SLUG
CI_ENVIRONMENT_ACTION CI_ENVIRONMENT_URL] CI_ENVIRONMENT_TIER CI_ENVIRONMENT_ACTION CI_ENVIRONMENT_URL]
end end
before do before do
...@@ -2820,7 +2820,8 @@ RSpec.describe Ci::Build do ...@@ -2820,7 +2820,8 @@ RSpec.describe Ci::Build do
let(:environment_variables) do let(:environment_variables) do
[ [
{ key: 'CI_ENVIRONMENT_NAME', value: 'production', public: true, masked: false }, { key: 'CI_ENVIRONMENT_NAME', value: 'production', public: true, masked: false },
{ key: 'CI_ENVIRONMENT_SLUG', value: 'prod-slug', public: true, masked: false } { key: 'CI_ENVIRONMENT_SLUG', value: 'prod-slug', public: true, masked: false },
{ key: 'CI_ENVIRONMENT_TIER', value: 'production', public: true, masked: false }
] ]
end end
...@@ -2829,6 +2830,7 @@ RSpec.describe Ci::Build do ...@@ -2829,6 +2830,7 @@ RSpec.describe Ci::Build do
project: build.project, project: build.project,
name: 'production', name: 'production',
slug: 'prod-slug', slug: 'prod-slug',
tier: 'production',
external_url: '') external_url: '')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment