summaryrefslogtreecommitdiff
path: root/app/services/ci/process_pipeline_service.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-04-16 13:14:39 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2017-05-07 22:43:53 +0200
commitf2a4420d66216e3a9172f4ab45c6b4fa96578117 (patch)
tree6b7c8845c085f804a02e2ead9109910fd30e667e /app/services/ci/process_pipeline_service.rb
parent6ad3814e1b31bfacfae7a2aabb4e4607b12ca66f (diff)
downloadgitlab-ce-f2a4420d66216e3a9172f4ab45c6b4fa96578117.tar.gz
Store retried in database for CI buildsretried-in-database-mysql
Diffstat (limited to 'app/services/ci/process_pipeline_service.rb')
-rw-r--r--app/services/ci/process_pipeline_service.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb
index 33edcd60944..647836de384 100644
--- a/app/services/ci/process_pipeline_service.rb
+++ b/app/services/ci/process_pipeline_service.rb
@@ -5,6 +5,8 @@ module Ci
def execute(pipeline)
@pipeline = pipeline
+ update_retried
+
new_builds =
stage_indexes_of_created_builds.map do |index|
process_stage(index)
@@ -71,5 +73,23 @@ module Ci
def created_builds
pipeline.builds.created
end
+
+ # This method is for compatibility and data consistency and should be removed with 9.3 version of GitLab
+ # This replicates what is db/post_migrate/20170416103934_upate_retried_for_ci_build.rb
+ # and ensures that functionality will not be broken before migration is run
+ # this updates only when there are data that needs to be updated, there are two groups with no retried flag
+ def update_retried
+ # find the latest builds for each name
+ latest_statuses = pipeline.statuses.latest
+ .group(:name)
+ .having('count(*) > 1')
+ .pluck('max(id)', 'name')
+
+ # mark builds that are retried
+ pipeline.statuses.latest
+ .where(name: latest_statuses.map(&:second))
+ .where.not(id: latest_statuses.map(&:first))
+ .update_all(retried: true) if latest_statuses.any?
+ end
end
end