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:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-07-19 14:23:14 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-07-19 15:53:35 +0300
commit41fa516bb67e97e59ad8a38fe8296bbd3a091c82 (patch)
tree26b335bd7354af2e85f1a5f04c2f13da39dfb105 /lib/ci/gitlab_ci_yaml_processor.rb
parent61e7453e0465ceb631d3e8445429cfed7c1449d3 (diff)
Use value of `yaml_variables` and `when` from config_processor if undefined
Diffstat (limited to 'lib/ci/gitlab_ci_yaml_processor.rb')
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb65
1 files changed, 33 insertions, 32 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index 41449d720b3..c45e3a95c7f 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -45,22 +45,50 @@ module Ci
def builds_for_ref(ref, tag = false, trigger_request = nil)
jobs_for_ref(ref, tag, trigger_request).map do |name, job|
- build_job(name, job)
+ build_attributes(name, _)
end
end
def builds_for_stage_and_ref(stage, ref, tag = false, trigger_request = nil)
- jobs_for_stage_and_ref(stage, ref, tag, trigger_request).map do |name, job|
- build_job(name, job)
+ jobs_for_stage_and_ref(stage, ref, tag, trigger_request).map do |name, _|
+ build_attributes(name)
end
end
def builds
- @jobs.map do |name, job|
- build_job(name, job)
+ @jobs.map do |name, _|
+ build_attributes(name)
end
end
+ def build_attributes(name)
+ job = @jobs[name.to_sym] || {}
+ {
+ stage_idx: @stages.index(job[:stage]),
+ stage: job[:stage],
+ ##
+ # Refactoring note:
+ # - before script behaves differently than after script
+ # - after script returns an array of commands
+ # - before script should be a concatenated command
+ commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"),
+ tag_list: job[:tags] || [],
+ name: name,
+ allow_failure: job[:allow_failure] || false,
+ when: job[:when] || 'on_success',
+ environment: job[:environment],
+ yaml_variables: yaml_variables(name),
+ options: {
+ image: job[:image] || @image,
+ services: job[:services] || @services,
+ artifacts: job[:artifacts],
+ cache: job[:cache] || @cache,
+ dependencies: job[:dependencies],
+ after_script: job[:after_script] || @after_script,
+ }.compact
+ }
+ end
+
private
def initial_parsing
@@ -89,33 +117,6 @@ module Ci
@jobs[name] = { stage: stage }.merge(job)
end
- def build_job(name, job)
- {
- stage_idx: @stages.index(job[:stage]),
- stage: job[:stage],
- ##
- # Refactoring note:
- # - before script behaves differently than after script
- # - after script returns an array of commands
- # - before script should be a concatenated command
- commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"),
- tag_list: job[:tags] || [],
- name: name,
- allow_failure: job[:allow_failure] || false,
- when: job[:when] || 'on_success',
- environment: job[:environment],
- yaml_variables: yaml_variables(name),
- options: {
- image: job[:image] || @image,
- services: job[:services] || @services,
- artifacts: job[:artifacts],
- cache: job[:cache] || @cache,
- dependencies: job[:dependencies],
- after_script: job[:after_script] || @after_script,
- }.compact
- }
- end
-
def yaml_variables(name)
variables = global_variables.merge(job_variables(name))
variables.map do |key, value|