debian-mirror-gitlab/lib/gitlab/ci/pipeline/chain/config/content.rb

63 lines
1.9 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Pipeline
module Chain
module Config
class Content < Chain::Base
include Chain::Helpers
2020-01-01 13:55:28 +05:30
SOURCES = [
2020-03-13 15:44:24 +05:30
Gitlab::Ci::Pipeline::Chain::Config::Content::Bridge,
2020-01-01 13:55:28 +05:30
Gitlab::Ci::Pipeline::Chain::Config::Content::Repository,
Gitlab::Ci::Pipeline::Chain::Config::Content::ExternalProject,
Gitlab::Ci::Pipeline::Chain::Config::Content::Remote,
Gitlab::Ci::Pipeline::Chain::Config::Content::AutoDevops
].freeze
LEGACY_SOURCES = [
2020-03-13 15:44:24 +05:30
Gitlab::Ci::Pipeline::Chain::Config::Content::Bridge,
2020-01-01 13:55:28 +05:30
Gitlab::Ci::Pipeline::Chain::Config::Content::LegacyRepository,
Gitlab::Ci::Pipeline::Chain::Config::Content::LegacyAutoDevops
].freeze
2019-12-26 22:10:19 +05:30
2020-01-01 13:55:28 +05:30
def perform!
if config = find_config
2020-03-13 15:44:24 +05:30
@pipeline.build_pipeline_config(content: config.content) if ci_root_config_content_enabled?
2020-01-01 13:55:28 +05:30
@command.config_content = config.content
@pipeline.config_source = config.source
else
error('Missing CI config file')
2019-12-26 22:10:19 +05:30
end
end
def break?
@pipeline.errors.any? || @pipeline.persisted?
end
private
2020-01-01 13:55:28 +05:30
def find_config
sources.each do |source|
config = source.new(@pipeline, @command)
return config if config.exists?
end
2019-12-26 22:10:19 +05:30
nil
end
2020-01-01 13:55:28 +05:30
def sources
2020-03-13 15:44:24 +05:30
ci_root_config_content_enabled? ? SOURCES : LEGACY_SOURCES
end
def ci_root_config_content_enabled?
Feature.enabled?(:ci_root_config_content, @command.project, default_enabled: true)
2019-12-26 22:10:19 +05:30
end
end
end
end
end
end
end