Commit 1c0e82ef authored by Markus Koller's avatar Markus Koller

Merge branch '335558-expose-deployment_tier-in-the-pipeline-events-webhook' into 'master'

Resolve "Expose `deployment_tier` in the “Pipeline events” webhook"

See merge request gitlab-org/gitlab!66744
parents 54e345fb 925656b9
...@@ -1157,7 +1157,8 @@ X-Gitlab-Event: Pipeline Hook ...@@ -1157,7 +1157,8 @@ X-Gitlab-Event: Pipeline Hook
}, },
"environment": { "environment": {
"name": "production", "name": "production",
"action": "start" "action": "start",
"deployment_tier": "production"
} }
}, },
{ {
...@@ -1291,7 +1292,8 @@ X-Gitlab-Event: Pipeline Hook ...@@ -1291,7 +1292,8 @@ X-Gitlab-Event: Pipeline Hook
}, },
"environment": { "environment": {
"name": "staging", "name": "staging",
"action": "start" "action": "start",
"deployment_tier": "staging"
} }
} }
] ]
......
...@@ -91,7 +91,8 @@ module Gitlab ...@@ -91,7 +91,8 @@ module Gitlab
{ {
name: build.expanded_environment_name, name: build.expanded_environment_name,
action: build.environment_action action: build.environment_action,
deployment_tier: build.persisted_environment.try(:tier)
} }
end end
end end
......
...@@ -120,6 +120,19 @@ FactoryBot.define do ...@@ -120,6 +120,19 @@ FactoryBot.define do
end end
end end
trait :environment_with_deployment_tier do
environment { 'test_portal' }
options do
{
script: %w(ls),
environment: { name: 'test_portal',
action: 'start',
url: 'http://staging.example.com/$CI_JOB_NAME',
deployment_tier: 'testing' }
}
end
end
trait :deploy_to_production do trait :deploy_to_production do
environment { 'production' } environment { 'production' }
......
...@@ -119,10 +119,14 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do ...@@ -119,10 +119,14 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
end end
context 'build with environment' do context 'build with environment' do
let!(:build) { create(:ci_build, :teardown_environment, pipeline: pipeline) } let!(:build) { create(:ci_build, :environment_with_deployment_tier, :with_deployment, pipeline: pipeline) }
let!(:build_environment_data) { build_data[:environment] }
it { expect(build_data[:environment][:name]).to eq(build.expanded_environment_name) } it 'has environment attributes', :aggregate_failures do
it { expect(build_data[:environment][:action]).to eq(build.environment_action) } expect(build_environment_data[:name]).to eq(build.expanded_environment_name)
expect(build_environment_data[:action]).to eq(build.environment_action)
expect(build_environment_data[:deployment_tier]).to eq(build.persisted_environment.try(:tier))
end
end end
end end
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