Commit 4b8337d4 authored by Kamil Trzciński's avatar Kamil Trzciński

Add Variables entry into Processable

Variables handling is generic for Job and Bridge
it is better to keep it's behaviour in a single place
parent 67502abd
......@@ -67,6 +67,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do
ignore: false,
stage: 'test',
only: { refs: %w[branches tags] },
variables: {},
scheduling_type: :dag)
end
end
......
......@@ -11,7 +11,7 @@ module Gitlab
class Bridge < ::Gitlab::Config::Entry::Node
include ::Gitlab::Ci::Config::Entry::Processable
ALLOWED_KEYS = %i[trigger allow_failure when variables needs].freeze
ALLOWED_KEYS = %i[trigger allow_failure when needs].freeze
validations do
validates :config, allowed_keys: ALLOWED_KEYS + PROCESSABLE_ALLOWED_KEYS
......@@ -45,10 +45,6 @@ module Gitlab
inherit: false,
metadata: { allowed_needs: %i[job bridge] }
entry :variables, ::Gitlab::Ci::Config::Entry::Variables,
description: 'Environment variables available for this job.',
inherit: false
attributes :when, :allow_failure
def self.matching?(name, config)
......@@ -67,7 +63,6 @@ module Gitlab
needs: (needs_value if needs_defined?),
ignore: !!allow_failure,
when: self.when,
variables: (variables_value if variables_defined?),
scheduling_type: needs_defined? && !bridge_needs ? :dag : :stage
).compact
end
......
......@@ -112,10 +112,6 @@ module Gitlab
metadata: { allowed_needs: %i[job cross_dependency] },
inherit: false
entry :variables, Entry::Variables,
description: 'Environment variables available for this job.',
inherit: false
entry :environment, Entry::Environment,
description: 'Environment configuration for this job.',
inherit: false
......@@ -174,7 +170,6 @@ module Gitlab
when: self.when,
start_in: self.start_in,
dependencies: dependencies,
variables: variables_defined? ? variables_value : {},
environment: environment_defined? ? environment_value : nil,
environment_name: environment_defined? ? environment_value[:name] : nil,
coverage: coverage_defined? ? coverage_value : nil,
......
......@@ -14,7 +14,7 @@ module Gitlab
include ::Gitlab::Config::Entry::Attributable
include ::Gitlab::Config::Entry::Inheritable
PROCESSABLE_ALLOWED_KEYS = %i[extends stage only except rules].freeze
PROCESSABLE_ALLOWED_KEYS = %i[extends stage only except rules variables].freeze
included do
validations do
......@@ -54,6 +54,10 @@ module Gitlab
allowed_when: %w[on_success on_failure always never manual delayed].freeze
}
entry :variables, ::Gitlab::Ci::Config::Entry::Variables,
description: 'Environment variables available for this job.',
inherit: false
attributes :extends, :rules
end
......@@ -90,6 +94,7 @@ module Gitlab
stage: stage_value,
extends: extends,
rules: rules_value,
variables: variables_defined? ? variables_value : {},
only: only_value,
except: except_value }.compact
end
......
......@@ -106,6 +106,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do
ignore: false,
stage: 'test',
only: { refs: %w[branches tags] },
variables: {},
scheduling_type: :stage)
end
end
......@@ -128,6 +129,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do
ignore: false,
stage: 'test',
only: { refs: %w[branches tags] },
variables: {},
scheduling_type: :stage)
end
end
......
......@@ -99,6 +99,7 @@ describe Gitlab::Ci::Config::Entry::Jobs do
only: { refs: %w[branches tags] },
stage: 'test',
trigger: { project: 'my/project' },
variables: {},
scheduling_type: :stage
},
regular_job: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment