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

80 lines
2.4 KiB
Ruby
Raw Normal View History

2019-09-30 21:07:59 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Entry
##
# This class represents a default entry
# Entry containing default values for all jobs
# defined in configuration file.
#
class Default < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Configurable
2019-12-26 22:10:19 +05:30
include ::Gitlab::Config::Entry::Inheritable
2019-09-30 21:07:59 +05:30
ALLOWED_KEYS = %i[before_script image services
2020-01-01 13:55:28 +05:30
after_script cache interruptible
timeout retry tags artifacts].freeze
2019-09-30 21:07:59 +05:30
validations do
validates :config, allowed_keys: ALLOWED_KEYS
end
entry :before_script, Entry::Script,
description: 'Script that will be executed before each job.',
inherit: true
entry :image, Entry::Image,
description: 'Docker image that will be used to execute jobs.',
inherit: true
entry :services, Entry::Services,
description: 'Docker images that will be linked to the container.',
inherit: true
entry :after_script, Entry::Script,
description: 'Script that will be executed after each job.',
inherit: true
2021-06-08 01:23:25 +05:30
entry :cache, Entry::Caches,
2019-09-30 21:07:59 +05:30
description: 'Configure caching between build jobs.',
inherit: true
2020-01-01 13:55:28 +05:30
entry :interruptible, ::Gitlab::Config::Entry::Boolean,
2019-12-26 22:10:19 +05:30
description: 'Set jobs interruptible default value.',
inherit: false
2019-09-30 21:07:59 +05:30
2020-01-01 13:55:28 +05:30
entry :timeout, Entry::Timeout,
description: 'Set jobs default timeout.',
inherit: false
entry :retry, Entry::Retry,
description: 'Set retry default value.',
inherit: false
entry :tags, ::Gitlab::Config::Entry::ArrayOfStrings,
description: 'Set the default tags.',
inherit: false
entry :artifacts, Entry::Artifacts,
description: 'Default artifacts.',
inherit: false
2019-09-30 21:07:59 +05:30
private
2019-12-26 22:10:19 +05:30
def overwrite_entry(deps, key, current_entry)
inherited_entry = deps[key]
2019-09-30 21:07:59 +05:30
2019-12-26 22:10:19 +05:30
if inherited_entry.specified? && current_entry.specified?
raise InheritError, "#{key} is defined in top-level and `default:` entry"
2019-09-30 21:07:59 +05:30
end
2019-12-26 22:10:19 +05:30
inherited_entry unless current_entry.specified?
2019-09-30 21:07:59 +05:30
end
end
end
end
end
end