Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/config.rb')
-rw-r--r--lib/gitlab/ci/config.rb31
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb
index aceaf012f7e..6f149385969 100644
--- a/lib/gitlab/ci/config.rb
+++ b/lib/gitlab/ci/config.rb
@@ -19,11 +19,12 @@ module Gitlab
attr_reader :root, :context, :source_ref_path, :source
- def initialize(config, project: nil, sha: nil, user: nil, parent_pipeline: nil, source_ref_path: nil, source: nil)
- @context = build_context(project: project, sha: sha, user: user, parent_pipeline: parent_pipeline, ref: source_ref_path)
+ def initialize(config, project: nil, pipeline: nil, sha: nil, user: nil, parent_pipeline: nil, source: nil)
+ @source_ref_path = pipeline&.source_ref_path
+
+ @context = build_context(project: project, pipeline: pipeline, sha: sha, user: user, parent_pipeline: parent_pipeline)
@context.set_deadline(TIMEOUT_SECONDS)
- @source_ref_path = source_ref_path
@source = source
@config = expand_config(config)
@@ -108,16 +109,16 @@ module Gitlab
end
end
- def build_context(project:, sha:, user:, parent_pipeline:, ref:)
+ def build_context(project:, pipeline:, sha:, user:, parent_pipeline:)
Config::External::Context.new(
project: project,
sha: sha || find_sha(project),
user: user,
parent_pipeline: parent_pipeline,
- variables: build_variables(project: project, ref: ref))
+ variables: build_variables(project: project, pipeline: pipeline))
end
- def build_variables(project:, ref:)
+ def build_variables(project:, pipeline:)
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless project
@@ -126,18 +127,12 @@ module Gitlab
#
# See more detail in the docs: https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
variables.concat(project.predefined_variables)
- variables.concat(pipeline_predefined_variables(ref: ref))
- variables.concat(project.ci_instance_variables_for(ref: ref))
- variables.concat(project.group.ci_variables_for(ref, project)) if project.group
- variables.concat(project.ci_variables_for(ref: ref))
- end
- end
-
- # https://gitlab.com/gitlab-org/gitlab/-/issues/337633 aims to add all predefined variables
- # to this list, but only CI_COMMIT_REF_NAME is available right now to support compliance pipelines.
- def pipeline_predefined_variables(ref:)
- Gitlab::Ci::Variables::Collection.new.tap do |v|
- v.append(key: 'CI_COMMIT_REF_NAME', value: ref)
+ variables.concat(pipeline.predefined_variables) if pipeline
+ variables.concat(project.ci_instance_variables_for(ref: source_ref_path))
+ variables.concat(project.group.ci_variables_for(source_ref_path, project)) if project.group
+ variables.concat(project.ci_variables_for(ref: source_ref_path))
+ variables.concat(pipeline.variables) if pipeline
+ variables.concat(pipeline.pipeline_schedule.job_variables) if pipeline&.pipeline_schedule
end
end