Commit da6157a5 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Move some predefined variables to reflect hierarchy

parent 76cf6c6a
...@@ -282,19 +282,14 @@ module Ci ...@@ -282,19 +282,14 @@ module Ci
# contain unexpanded variables. # contain unexpanded variables.
def variables(environment: persisted_environment) def variables(environment: persisted_environment)
variables = predefined_variables variables = predefined_variables
variables += project.predefined_variables
variables += pipeline.predefined_variables variables += pipeline.predefined_variables
variables += runner.predefined_variables if runner variables += runner.predefined_variables if runner
variables += project.container_registry_variables
variables += project.deployment_variables if has_environment? variables += project.deployment_variables if has_environment?
variables += project.auto_devops_variables
variables += yaml_variables variables += yaml_variables
variables += user_variables variables += user_variables
variables += project.group.secret_variables_for(ref, project).map(&:to_runner_variable) if project.group variables += project.group.secret_variables_for(ref, project).map(&:to_runner_variable) if project.group
variables += secret_variables(environment: environment) variables += secret_variables(environment: environment)
variables += trigger_request.user_variables if trigger_request variables += trigger_request.user_variables if trigger_request
variables += pipeline.variables.map(&:to_runner_variable)
variables += pipeline.pipeline_schedule.job_variables if pipeline.pipeline_schedule
variables += persisted_environment_variables if environment variables += persisted_environment_variables if environment
variables variables
...@@ -570,12 +565,6 @@ module Ci ...@@ -570,12 +565,6 @@ module Ci
def predefined_variables def predefined_variables
variables = [ variables = [
{ key: 'CI', value: 'true', public: true },
{ key: 'GITLAB_CI', value: 'true', public: true },
{ key: 'GITLAB_FEATURES', value: project.namespace.features.join(','), public: true },
{ key: 'CI_SERVER_NAME', value: 'GitLab', public: true },
{ key: 'CI_SERVER_VERSION', value: Gitlab::VERSION, public: true },
{ key: 'CI_SERVER_REVISION', value: Gitlab::REVISION, public: true },
{ key: 'CI_JOB_ID', value: id.to_s, public: true }, { key: 'CI_JOB_ID', value: id.to_s, public: true },
{ key: 'CI_JOB_NAME', value: name, public: true }, { key: 'CI_JOB_NAME', value: name, public: true },
{ key: 'CI_JOB_STAGE', value: stage, public: true }, { key: 'CI_JOB_STAGE', value: stage, public: true },
......
...@@ -473,11 +473,21 @@ module Ci ...@@ -473,11 +473,21 @@ module Ci
end end
def predefined_variables def predefined_variables
[ variables = [
{ key: 'CI', value: 'true', public: true },
{ key: 'GITLAB_CI', value: 'true', public: true },
{ key: 'GITLAB_FEATURES', value: project.namespace.features.join(','), public: true },
{ key: 'CI_SERVER_NAME', value: 'GitLab', public: true },
{ key: 'CI_SERVER_VERSION', value: Gitlab::VERSION, public: true },
{ key: 'CI_SERVER_REVISION', value: Gitlab::REVISION, public: true },
{ key: 'CI_PIPELINE_ID', value: id.to_s, public: true }, { key: 'CI_PIPELINE_ID', value: id.to_s, public: true },
{ key: 'CI_CONFIG_PATH', value: ci_yaml_file_path, public: true }, { key: 'CI_CONFIG_PATH', value: ci_yaml_file_path, public: true },
{ key: 'CI_PIPELINE_SOURCE', value: source.to_s, public: true } { key: 'CI_PIPELINE_SOURCE', value: source.to_s, public: true }
] ]
variables += project.predefined_variables
variables += variables.map(&:to_runner_variable)
variables += pipeline_schedule.job_variables if pipeline_schedule
end end
def queued_duration def queued_duration
......
...@@ -1554,7 +1554,7 @@ class Project < ActiveRecord::Base ...@@ -1554,7 +1554,7 @@ class Project < ActiveRecord::Base
end end
def predefined_variables def predefined_variables
[ variables = [
{ key: 'CI_PROJECT_ID', value: id.to_s, public: true }, { key: 'CI_PROJECT_ID', value: id.to_s, public: true },
{ key: 'CI_PROJECT_NAME', value: path, public: true }, { key: 'CI_PROJECT_NAME', value: path, public: true },
{ key: 'CI_PROJECT_PATH', value: full_path, public: true }, { key: 'CI_PROJECT_PATH', value: full_path, public: true },
...@@ -1563,6 +1563,9 @@ class Project < ActiveRecord::Base ...@@ -1563,6 +1563,9 @@ class Project < ActiveRecord::Base
{ key: 'CI_PROJECT_URL', value: web_url, public: true }, { key: 'CI_PROJECT_URL', value: web_url, public: true },
{ key: 'CI_PROJECT_VISIBILITY', value: Gitlab::VisibilityLevel.string_level(visibility_level), public: true } { key: 'CI_PROJECT_VISIBILITY', value: Gitlab::VisibilityLevel.string_level(visibility_level), public: true }
] ]
variables += container_registry_variables
variables += auto_devops_variables
end end
def container_registry_variables def container_registry_variables
......
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