2019-11-17 16:06:14 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Build
|
|
|
|
module Context
|
|
|
|
class Global < Base
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
|
|
|
def initialize(pipeline, yaml_variables:)
|
|
|
|
super(pipeline)
|
|
|
|
|
|
|
|
@yaml_variables = yaml_variables.to_a
|
|
|
|
end
|
|
|
|
|
|
|
|
def variables
|
|
|
|
strong_memoize(:variables) do
|
|
|
|
# This is a temporary piece of technical debt to allow us access
|
|
|
|
# to the CI variables to evaluate workflow:rules
|
|
|
|
# with the result. We should refactor away the extra Build.new,
|
|
|
|
# but be able to get CI Variables directly from the Seed::Build.
|
2021-03-02 16:11:07 -05:00
|
|
|
stub_build.scoped_variables.reject { |var| var[:key] =~ /\ACI_(JOB|BUILD)/ }
|
2019-11-17 16:06:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def stub_build
|
|
|
|
::Ci::Build.new(build_attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_attributes
|
|
|
|
pipeline_attributes.merge(
|
|
|
|
yaml_variables: @yaml_variables)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|