Commit 925656b9 authored by Bala Kumar's avatar Bala Kumar Committed by Markus Koller

Include deployment_tier to pipeline environment hook attributes

We have a [customer request](https://gitlab.com/gitlab-org/gitlab/-/issues/335558) to include `deployment_tier` to the pipeline webhook event payload. In this [MR](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66744) we are making changes for the same.

Changelog: changed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66744
parent 385083ea
......@@ -1157,7 +1157,8 @@ X-Gitlab-Event: Pipeline Hook
},
"environment": {
"name": "production",
"action": "start"
"action": "start",
"deployment_tier": "production"
}
},
{
......@@ -1291,7 +1292,8 @@ X-Gitlab-Event: Pipeline Hook
},
"environment": {
"name": "staging",
"action": "start"
"action": "start",
"deployment_tier": "staging"
}
}
]
......
......@@ -91,7 +91,8 @@ module Gitlab
{
name: build.expanded_environment_name,
action: build.environment_action
action: build.environment_action,
deployment_tier: build.persisted_environment.try(:tier)
}
end
end
......
......@@ -120,6 +120,19 @@ FactoryBot.define do
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
environment { 'production' }
......
......@@ -119,10 +119,14 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
end
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 { expect(build_data[:environment][:action]).to eq(build.environment_action) }
it 'has environment attributes', :aggregate_failures do
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
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