debian-mirror-gitlab/lib/gitlab/ci/pipeline/chain/populate.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

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!
2021-02-22 17:27:13 +05:30
raise ArgumentError, 'missing pipeline seed' unless @command.pipeline_seed
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.
#
2021-02-22 17:27:13 +05:30
pipeline.stages = @command.pipeline_seed.stages
2019-10-12 21:52:04 +05:30
2020-03-13 15:44:24 +05:30
if stage_names.empty?
2018-05-09 12:01:36 +05:30
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
2020-03-13 15:44:24 +05:30
private
def stage_names
# We filter out `.pre/.post` stages, as they alone are not considered
# a complete pipeline:
# https://gitlab.com/gitlab-org/gitlab/issues/198518
pipeline.stages.map(&:name) - ::Gitlab::Ci::Config::EdgeStagesInjector::EDGES
end
2018-05-09 12:01:36 +05:30
end
end
end
end
end