Fix create_next_builds method

This commit is contained in:
Kamil Trzcinski 2016-04-12 11:15:19 +02:00
parent ac50f9dddf
commit 1ae797c229
2 changed files with 3 additions and 22 deletions

View file

@ -116,12 +116,12 @@ module Ci
next_stages.delete(build.stage) next_stages.delete(build.stage)
# get status for all prior builds # get status for all prior builds
prior_builds = latest_builds.reject { |other_build| next_stages.include?(other_build.stage) } prior_builds = latest_builds.where.not(stage: next_stages)
status = prior_builds.status prior_status = prior_builds.status
# create builds for next stages based # create builds for next stages based
next_stages.any? do |stage| next_stages.any? do |stage|
CreateBuildsService.new(self).execute(stage, build.user, status, build.trigger_request).present? CreateBuildsService.new(self).execute(stage, build.user, prior_status, build.trigger_request).present?
end end
end end

View file

@ -1,19 +0,0 @@
module Ci
class Status
def self.get_status(statuses)
if statuses.none?
'skipped'
elsif statuses.all? { |status| status.success? || status.ignored? }
'success'
elsif statuses.all?(&:pending?)
'pending'
elsif statuses.any?(&:running?) || statuses.any?(&:pending?)
'running'
elsif statuses.all?(&:canceled?)
'canceled'
else
'failed'
end
end
end
end