diff --git a/app/services/ci/create_pipeline_builds_service.rb b/app/services/ci/create_pipeline_builds_service.rb index c7a624f38cefd690c136834ce3a7a7f6a3f2c405..3c12b806438501403e7aaa1c0155fb733f7a1543 100644 --- a/app/services/ci/create_pipeline_builds_service.rb +++ b/app/services/ci/create_pipeline_builds_service.rb @@ -13,16 +13,25 @@ module Ci private def create_build(build_attributes) - build_attributes = build_attributes.merge( + build_attributes = { + stage_idx: build_attributes[:stage_idx], + stage: build_attributes[:stage], + commands: build_attributes[:commands], + tag_list: build_attributes[:tag_list], + name: build_attributes[:name], + when: build_attributes[:when], + allow_failure: build_attributes[:allow_failure], + environment: build_attributes[:environment], + yaml_variables: build_attributes[:yaml_variables], + options: build_attributes[:options], pipeline: pipeline, project: pipeline.project, ref: pipeline.ref, tag: pipeline.tag, user: current_user, trigger_request: trigger_request - ) - # OPTIMIZE: We copy over all attributes of Job into Build, therefore this workaround - build_attributes = build_attributes.except(:only, :except) + } + pipeline.builds.create(build_attributes) end diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 6dedd25e9d321fb50c0f9365b472b1b7770c392f..317259f0c273ad18d327f797fe87aa8dcba9ec2a 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -26,7 +26,9 @@ module Ci allow_failure: false, when: "on_success", environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end @@ -443,7 +445,9 @@ module Ci allow_failure: false, when: "on_success", environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end @@ -471,7 +475,9 @@ module Ci allow_failure: false, when: "on_success", environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end end @@ -716,7 +722,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end @@ -859,7 +867,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end end @@ -904,7 +914,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) expect(subject.second).to eq({ stage: "build", @@ -916,7 +928,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end end