2016-06-06 03:24:16 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
|
|
|
module Node
|
2016-06-09 07:01:19 -04:00
|
|
|
##
|
|
|
|
# This class represents a global entry - root node for entire
|
|
|
|
# GitLab CI Configuration file.
|
|
|
|
#
|
2016-06-06 03:24:16 -04:00
|
|
|
class Global < Entry
|
2016-06-09 04:08:49 -04:00
|
|
|
include Configurable
|
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :before_script, Node::Script,
|
2016-06-09 04:53:56 -04:00
|
|
|
description: 'Script that will be executed before each job.'
|
2016-06-21 06:10:13 -04:00
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :image, Node::Image,
|
2016-06-21 06:10:13 -04:00
|
|
|
description: 'Docker image that will be used to execute jobs.'
|
2016-06-21 06:40:52 -04:00
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :services, Node::Services,
|
2016-06-21 06:40:52 -04:00
|
|
|
description: 'Docker images that will be linked to the container.'
|
2016-06-21 07:02:14 -04:00
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :after_script, Node::Script,
|
2016-06-21 07:02:14 -04:00
|
|
|
description: 'Script that will be executed after each job.'
|
2016-06-22 05:22:53 -04:00
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :variables, Node::Variables,
|
2016-06-22 05:22:53 -04:00
|
|
|
description: 'Environment variables that will be used.'
|
2016-06-23 07:51:07 -04:00
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :stages, Node::Stages,
|
2016-06-23 07:51:07 -04:00
|
|
|
description: 'Configuration of stages for this pipeline.'
|
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :types, Node::Stages,
|
2016-06-30 06:59:17 -04:00
|
|
|
description: 'Deprecated: stages for this pipeline.'
|
2016-06-23 07:51:07 -04:00
|
|
|
|
2016-06-29 06:20:45 -04:00
|
|
|
node :cache, Node::Cache,
|
2016-06-29 03:39:04 -04:00
|
|
|
description: 'Configure caching between build jobs.'
|
|
|
|
|
|
|
|
helpers :before_script, :image, :services, :after_script,
|
2016-07-05 07:35:50 -04:00
|
|
|
:variables, :stages, :types, :cache, :jobs
|
2016-06-24 04:13:55 -04:00
|
|
|
|
2016-07-09 10:51:26 -04:00
|
|
|
def initialize(*)
|
|
|
|
super
|
2016-07-09 12:43:26 -04:00
|
|
|
|
2016-07-08 05:29:03 -04:00
|
|
|
@global = self
|
2016-07-05 07:07:03 -04:00
|
|
|
end
|
|
|
|
|
2016-07-09 10:51:26 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def compose!
|
|
|
|
super
|
|
|
|
|
|
|
|
compose_stages!
|
|
|
|
compose_jobs!
|
2016-06-23 07:51:07 -04:00
|
|
|
end
|
2016-07-07 09:00:35 -04:00
|
|
|
|
2016-07-09 11:38:03 -04:00
|
|
|
def compose_jobs!
|
2016-07-09 10:51:26 -04:00
|
|
|
factory = Node::Factory.new(Node::Jobs)
|
|
|
|
factory.value(@config.except(*nodes.keys))
|
|
|
|
factory.with(key: :jobs, parent: self, global: self)
|
|
|
|
factory.with(description: 'Jobs definition for this pipeline')
|
2016-07-08 05:29:03 -04:00
|
|
|
|
2016-07-09 10:51:26 -04:00
|
|
|
@entries[:jobs] = factory.create!
|
|
|
|
end
|
2016-07-08 05:29:03 -04:00
|
|
|
|
2016-07-09 11:38:03 -04:00
|
|
|
def compose_stages!
|
|
|
|
##
|
|
|
|
# Deprecated `:types` key workaround - if types are defined and
|
|
|
|
# stages are not defined we use types definition as stages.
|
|
|
|
#
|
|
|
|
# Otherwise we use stages in favor of types, and remove types from
|
|
|
|
# processing.
|
|
|
|
#
|
2016-07-09 10:51:26 -04:00
|
|
|
if types_defined? && !stages_defined?
|
|
|
|
@entries[:stages] = @entries[:types]
|
|
|
|
end
|
2016-07-08 05:29:03 -04:00
|
|
|
|
2016-07-09 10:51:26 -04:00
|
|
|
@entries.delete(:types)
|
2016-07-07 09:00:35 -04:00
|
|
|
end
|
2016-06-06 03:24:16 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|