2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Pipeline
|
|
|
|
module Chain
|
|
|
|
class Populate < Chain::Base
|
|
|
|
include Chain::Helpers
|
|
|
|
|
|
|
|
PopulateError = Class.new(StandardError)
|
|
|
|
|
|
|
|
def perform!
|
2019-12-26 22:10:19 +05:30
|
|
|
raise ArgumentError, 'missing stage seeds' unless @command.stage_seeds
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
##
|
|
|
|
# Populate pipeline with all stages, and stages with builds.
|
|
|
|
#
|
2019-12-26 22:10:19 +05:30
|
|
|
pipeline.stages = @command.stage_seeds.map(&:to_resource)
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
if pipeline.stages.none?
|
|
|
|
return error('No stages / jobs for this pipeline.')
|
|
|
|
end
|
|
|
|
|
|
|
|
if pipeline.invalid?
|
|
|
|
return error('Failed to build the pipeline!')
|
|
|
|
end
|
|
|
|
|
|
|
|
raise Populate::PopulateError if pipeline.persisted?
|
|
|
|
end
|
|
|
|
|
|
|
|
def break?
|
|
|
|
pipeline.errors.any?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|