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/variables/builder.rb')
-rw-r--r--lib/gitlab/ci/variables/builder.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/gitlab/ci/variables/builder.rb b/lib/gitlab/ci/variables/builder.rb
index 528d72c9bcc..cf5f04215ad 100644
--- a/lib/gitlab/ci/variables/builder.rb
+++ b/lib/gitlab/ci/variables/builder.rb
@@ -11,6 +11,7 @@ module Gitlab
@instance_variables_builder = Builder::Instance.new
@project_variables_builder = Builder::Project.new(project)
@group_variables_builder = Builder::Group.new(project&.group)
+ @release_variables_builder = Builder::Release.new(release)
end
def scoped_variables(job, environment:, dependencies:)
@@ -28,6 +29,7 @@ module Gitlab
variables.concat(secret_project_variables(environment: environment))
variables.concat(pipeline.variables)
variables.concat(pipeline_schedule_variables)
+ variables.concat(release_variables)
end
end
@@ -106,18 +108,26 @@ module Gitlab
end
end
+ def release_variables
+ strong_memoize(:release_variables) do
+ release_variables_builder.variables
+ end
+ end
+
private
attr_reader :pipeline
attr_reader :instance_variables_builder
attr_reader :project_variables_builder
attr_reader :group_variables_builder
+ attr_reader :release_variables_builder
delegate :project, to: :pipeline
def predefined_variables(job)
Gitlab::Ci::Variables::Collection.new.tap do |variables|
variables.append(key: 'CI_JOB_NAME', value: job.name)
+ variables.append(key: 'CI_JOB_NAME_SLUG', value: job_name_slug(job))
variables.append(key: 'CI_JOB_STAGE', value: job.stage_name)
variables.append(key: 'CI_JOB_MANUAL', value: 'true') if job.action?
variables.append(key: 'CI_PIPELINE_TRIGGERED', value: 'true') if job.trigger_request
@@ -145,6 +155,10 @@ module Gitlab
end
end
+ def job_name_slug(job)
+ job.name && Gitlab::Utils.slugify(job.name)
+ end
+
def ci_node_total_value(job)
parallel = job.options&.dig(:parallel)
parallel = parallel.dig(:total) if parallel.is_a?(Hash)
@@ -166,6 +180,12 @@ module Gitlab
container[args] = yield
end
end
+
+ def release
+ return unless @pipeline.tag?
+
+ project.releases.find_by_tag(@pipeline.ref)
+ end
end
end
end