Skip to content
Snippets Groups Projects
Verified Commit 891a4821 authored by Matija Čupić's avatar Matija Čupić
Browse files

Copy variables when retrying job

Changelog: changed
parent 44f0c50e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1075,6 +1075,16 @@ def shared_runner_build?
runner&.instance_type?
end
 
def job_variables_attributes
strong_memoize(:job_variables_attributes) do
job_variables.map do |variable|
variable.attributes.except('id', 'job_id', 'encrypted_value', 'encrypted_value_iv').tap do |attrs|
attrs[:value] = variable.value
end
end
end
end
protected
 
def run_status_commit_hooks!
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ def self.clone_accessors
allow_failure stage stage_id stage_idx trigger_request
yaml_variables when environment coverage_regex
description tag_list protected needs_attributes
resource_group scheduling_type].freeze
resource_group scheduling_type job_variables_attributes].freeze
end
 
def self.extra_accessors
Loading
Loading
Loading
Loading
@@ -125,6 +125,14 @@
expect(new_build.needs_attributes).to match(build.needs_attributes)
expect(new_build.needs).not_to match(build.needs)
end
it 'clones only the job variables attributes' do
expect(new_build.job_variables.exists?).to be_truthy
expect(build.job_variables.exists?).to be_truthy
expect(new_build.job_variables_attributes).to match(build.job_variables_attributes)
expect(new_build.job_variables).not_to match(build.job_variables)
end
end
 
describe 'reject accessors' do
Loading
Loading
@@ -147,7 +155,7 @@
Ci::Build.attribute_names.map(&:to_sym) +
Ci::Build.attribute_aliases.keys.map(&:to_sym) +
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
described_class.extra_accessors -
[:dast_site_profiles_build, :dast_scanner_profiles_build] # join tables
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment