debian-mirror-gitlab/lib/gitlab/ci/config/entry/global.rb

77 lines
2.3 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
class Config
2017-08-17 22:00:37 +05:30
module Entry
##
2017-08-17 22:00:37 +05:30
# This class represents a global entry - root Entry for entire
# GitLab CI Configuration file.
#
2017-08-17 22:00:37 +05:30
class Global < Node
include Configurable
2017-08-17 22:00:37 +05:30
entry :before_script, Entry::Script,
description: 'Script that will be executed before each job.'
2016-08-24 12:49:21 +05:30
2017-08-17 22:00:37 +05:30
entry :image, Entry::Image,
2016-08-24 12:49:21 +05:30
description: 'Docker image that will be used to execute jobs.'
2017-08-17 22:00:37 +05:30
entry :services, Entry::Services,
2016-08-24 12:49:21 +05:30
description: 'Docker images that will be linked to the container.'
2017-08-17 22:00:37 +05:30
entry :after_script, Entry::Script,
2016-08-24 12:49:21 +05:30
description: 'Script that will be executed after each job.'
2017-08-17 22:00:37 +05:30
entry :variables, Entry::Variables,
2016-08-24 12:49:21 +05:30
description: 'Environment variables that will be used.'
2017-08-17 22:00:37 +05:30
entry :stages, Entry::Stages,
2016-08-24 12:49:21 +05:30
description: 'Configuration of stages for this pipeline.'
2017-08-17 22:00:37 +05:30
entry :types, Entry::Stages,
2016-08-24 12:49:21 +05:30
description: 'Deprecated: stages for this pipeline.'
2017-08-17 22:00:37 +05:30
entry :cache, Entry::Cache,
2016-08-24 12:49:21 +05:30
description: 'Configure caching between build jobs.'
helpers :before_script, :image, :services, :after_script,
2016-09-13 17:45:13 +05:30
:variables, :stages, :types, :cache, :jobs
2016-08-24 12:49:21 +05:30
2016-09-29 09:46:39 +05:30
def compose!(_deps = nil)
super(self) do
compose_jobs!
compose_deprecated_entries!
end
2016-09-13 17:45:13 +05:30
end
2016-09-29 09:46:39 +05:30
private
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2016-09-13 17:45:13 +05:30
def compose_jobs!
2017-08-17 22:00:37 +05:30
factory = Entry::Factory.new(Entry::Jobs)
2016-09-13 17:45:13 +05:30
.value(@config.except(*self.class.nodes.keys))
.with(key: :jobs, parent: self,
description: 'Jobs definition for this pipeline')
@entries[:jobs] = factory.create!
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2016-09-13 17:45:13 +05:30
def compose_deprecated_entries!
##
# Deprecated `:types` key workaround - if types are defined and
# stages are not defined we use types definition as stages.
#
if types_defined? && !stages_defined?
@entries[:stages] = @entries[:types]
end
@entries.delete(:types)
2016-08-24 12:49:21 +05:30
end
end
end
end
end
end