Commit cacedf0f authored by Matija Čupić's avatar Matija Čupić

Clean up clone_job_variables_at_job_retry

Changelog: changed
parent 39460c1a
...@@ -7,7 +7,7 @@ module Ci ...@@ -7,7 +7,7 @@ module Ci
allow_failure stage stage_id stage_idx trigger_request allow_failure stage stage_id stage_idx trigger_request
yaml_variables when environment coverage_regex yaml_variables when environment coverage_regex
description tag_list protected needs_attributes description tag_list protected needs_attributes
resource_group scheduling_type].freeze job_variables_attributes resource_group scheduling_type].freeze
end end
def self.extra_accessors def self.extra_accessors
...@@ -68,13 +68,7 @@ module Ci ...@@ -68,13 +68,7 @@ module Ci
end end
def build_attributes(build) def build_attributes(build)
clone_attributes = if ::Feature.enabled?(:clone_job_variables_at_job_retry, build.project, default_enabled: :yaml) attributes = self.class.clone_accessors.to_h do |attribute|
self.class.clone_accessors + [:job_variables_attributes]
else
self.class.clone_accessors
end
attributes = clone_attributes.to_h do |attribute|
[attribute, build.public_send(attribute)] # rubocop:disable GitlabSecurity/PublicSend [attribute, build.public_send(attribute)] # rubocop:disable GitlabSecurity/PublicSend
end end
......
---
name: clone_job_variables_at_job_retry
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75720
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/347156
milestone: '14.6'
type: development
group: group::pipeline authoring
default_enabled: false
...@@ -128,25 +128,9 @@ RSpec.describe Ci::RetryBuildService do ...@@ -128,25 +128,9 @@ RSpec.describe Ci::RetryBuildService do
expect(new_build.needs).not_to match(build.needs) expect(new_build.needs).not_to match(build.needs)
end end
context 'when clone_job_variables_at_job_retry is enabled' do it 'clones only internal job variables' do
before do expect(new_build.job_variables.count).to eq(1)
stub_feature_flags(clone_job_variables_at_job_retry: true) expect(new_build.job_variables).to contain_exactly(having_attributes(key: internal_job_variable.key, value: internal_job_variable.value))
end
it 'clones only internal job variables' do
expect(new_build.job_variables.count).to eq(1)
expect(new_build.job_variables).to contain_exactly(having_attributes(key: internal_job_variable.key, value: internal_job_variable.value))
end
end
context 'when clone_job_variables_at_job_retry is not enabled' do
before do
stub_feature_flags(clone_job_variables_at_job_retry: false)
end
it 'does not clone internal job variables' do
expect(new_build.job_variables.count).to eq(0)
end
end end
end end
...@@ -170,7 +154,7 @@ RSpec.describe Ci::RetryBuildService do ...@@ -170,7 +154,7 @@ RSpec.describe Ci::RetryBuildService do
Ci::Build.attribute_names.map(&:to_sym) + Ci::Build.attribute_names.map(&:to_sym) +
Ci::Build.attribute_aliases.keys.map(&:to_sym) + Ci::Build.attribute_aliases.keys.map(&:to_sym) +
Ci::Build.reflect_on_all_associations.map(&:name) + Ci::Build.reflect_on_all_associations.map(&:name) +
[:tag_list, :needs_attributes] - [:tag_list, :needs_attributes, :job_variables_attributes] -
# ee-specific accessors should be tested in ee/spec/services/ci/retry_build_service_spec.rb instead # ee-specific accessors should be tested in ee/spec/services/ci/retry_build_service_spec.rb instead
described_class.extra_accessors - described_class.extra_accessors -
[:dast_site_profiles_build, :dast_scanner_profiles_build] # join tables [:dast_site_profiles_build, :dast_scanner_profiles_build] # join tables
......
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