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 'app/models/concerns/ci')
-rw-r--r--app/models/concerns/ci/contextable.rb47
-rw-r--r--app/models/concerns/ci/has_variable.rb17
2 files changed, 20 insertions, 44 deletions
diff --git a/app/models/concerns/ci/contextable.rb b/app/models/concerns/ci/contextable.rb
index ed3b422251f..88b7bb89b89 100644
--- a/app/models/concerns/ci/contextable.rb
+++ b/app/models/concerns/ci/contextable.rb
@@ -11,26 +11,9 @@ module Ci
#
def scoped_variables(environment: expanded_environment_name, dependencies: true)
track_duration do
- variables = pipeline.variables_builder.scoped_variables(self, environment: environment, dependencies: dependencies)
-
- next variables if pipeline.use_variables_builder_definitions?
-
- variables.concat(project.predefined_variables)
- variables.concat(pipeline.predefined_variables)
- variables.concat(runner.predefined_variables) if runnable? && runner
- variables.concat(kubernetes_variables)
- variables.concat(deployment_variables(environment: environment))
- variables.concat(yaml_variables)
- variables.concat(user_variables)
- variables.concat(dependency_variables) if dependencies
- variables.concat(secret_instance_variables)
- variables.concat(secret_group_variables(environment: environment))
- variables.concat(secret_project_variables(environment: environment))
- variables.concat(trigger_request.user_variables) if trigger_request
- variables.concat(pipeline.variables)
- variables.concat(pipeline.pipeline_schedule.job_variables) if pipeline.pipeline_schedule
-
- variables
+ pipeline
+ .variables_builder
+ .scoped_variables(self, environment: environment, dependencies: dependencies)
end
end
@@ -60,29 +43,5 @@ module Ci
scoped_variables(environment: nil, dependencies: false)
end
end
-
- def user_variables
- pipeline.variables_builder.user_variables(user)
- end
-
- def kubernetes_variables
- pipeline.variables_builder.kubernetes_variables(self)
- end
-
- def deployment_variables(environment:)
- pipeline.variables_builder.deployment_variables(job: self, environment: environment)
- end
-
- def secret_instance_variables
- pipeline.variables_builder.secret_instance_variables(ref: git_ref)
- end
-
- def secret_group_variables(environment: expanded_environment_name)
- pipeline.variables_builder.secret_group_variables(environment: environment, ref: git_ref)
- end
-
- def secret_project_variables(environment: expanded_environment_name)
- pipeline.variables_builder.secret_project_variables(environment: environment, ref: git_ref)
- end
end
end
diff --git a/app/models/concerns/ci/has_variable.rb b/app/models/concerns/ci/has_variable.rb
index 7309469c77e..3b437fbba16 100644
--- a/app/models/concerns/ci/has_variable.rb
+++ b/app/models/concerns/ci/has_variable.rb
@@ -31,7 +31,24 @@ module Ci
end
def to_runner_variable
+ var_cache_key = to_runner_variable_cache_key
+
+ return uncached_runner_variable unless var_cache_key
+
+ ::Gitlab::SafeRequestStore.fetch(var_cache_key) { uncached_runner_variable }
+ end
+
+ private
+
+ def uncached_runner_variable
{ key: key, value: value, public: false, file: file? }
end
+
+ def to_runner_variable_cache_key
+ return unless persisted?
+
+ variable_id = read_attribute(self.class.primary_key)
+ "#{self.class}#to_runner_variable:#{variable_id}:#{key}"
+ end
end
end