summaryrefslogtreecommitdiff
path: root/app/services/ci/process_pipeline_service.rb
diff options
context:
space:
mode:
authorRegis Boudinot <boudinot.regis@yahoo.com>2017-05-10 22:07:05 +0000
committerRegis Boudinot <boudinot.regis@yahoo.com>2017-05-10 22:07:05 +0000
commit81df0034f4b66f2627ecd92f0ca44b7a3a634719 (patch)
tree1fc94d4e272b314dbe8b484e5c7d4cbf9faffb6c /app/services/ci/process_pipeline_service.rb
parent4086fca0f4dba977874c4b79b46578d6d603bfc5 (diff)
parent7eaab72b983a89040a01b9f32184fef258fb29f2 (diff)
downloadgitlab-ce-81df0034f4b66f2627ecd92f0ca44b7a3a634719.tar.gz
Merge branch 'retried-in-database-mysql' into 'master'
Retried in database Closes #25737 See merge request !11115
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 25ba54ffa0d..55af193d717 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