diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-02-16 13:13:10 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-02-16 13:13:10 +0100 |
commit | 953e590b18289005c69b72575ae6f38161ffa11b (patch) | |
tree | d47e5a38ae58163d055f6692112d6a1ac6b073c5 /app | |
parent | 658c5f32a3eac2f4a478e84ad767ba000041b461 (diff) | |
download | gitlab-ce-953e590b18289005c69b72575ae6f38161ffa11b.tar.gz |
Make build clone/retry implementation more robustfix/gb/pipeline-retry-builds-started
Diffstat (limited to 'app')
-rw-r--r-- | app/services/ci/retry_build_service.rb | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb index 4c4518d8029..4b47ee489cf 100644 --- a/app/services/ci/retry_build_service.rb +++ b/app/services/ci/retry_build_service.rb @@ -1,5 +1,18 @@ module Ci class RetryBuildService < ::BaseService + CLONE_ATTRIBUTES = %i[pipeline ref tag options commands tag_list name + allow_failure stage stage_idx trigger_request + yaml_variables when environment coverage_regex] + .freeze + + REJECT_ATTRIBUTES = %i[id status user token coverage trace runner + artifacts_file artifacts_metadata artifacts_size + created_at updated_at started_at finished_at + queued_at erased_by erased_at].freeze + + IGNORE_ATTRIBUTES = %i[trace type lock_version project target_url + deploy job_id description].freeze + def execute(build) reprocess(build).tap do |new_build| build.pipeline.mark_as_processable_after_stage(build.stage_idx) @@ -17,24 +30,13 @@ module Ci raise Gitlab::Access::AccessDeniedError end - Ci::Build.create( - ref: build.ref, - tag: build.tag, - options: build.options, - commands: build.commands, - tag_list: build.tag_list, - project: build.project, - pipeline: build.pipeline, - name: build.name, - allow_failure: build.allow_failure, - stage: build.stage, - stage_idx: build.stage_idx, - trigger_request: build.trigger_request, - yaml_variables: build.yaml_variables, - when: build.when, - environment: build.environment, - coverage_regex: build.coverage_regex, - user: current_user) + attributes = CLONE_ATTRIBUTES.map do |attribute| + [attribute, build.send(attribute)] + end + + attributes.push([:user, current_user]) + + project.builds.create(Hash[attributes]) end end end |