summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPascal Bach <pascal.bach@siemens.com>2016-02-24 15:48:56 +0100
committerPascal Bach <pascal.bach@siemens.com>2016-03-08 08:49:32 +0100
commit344d6e6f89cceb33e371e10de8262154ee108fbe (patch)
tree5b5944b926c9135e6db3c6abd661b5788d92d786 /spec
parent75a67ac0c72b24b07d6fa032e92997eb66ec226e (diff)
downloadgitlab-ce-344d6e6f89cceb33e371e10de8262154ee108fbe.tar.gz
Support YAML alias/anchor usage in .gitlab-ci.yml
This allows to reuse one job as a template for another one: ``` job1: &JOBTMPL script: execute-script-for-job job2: *JOBTMPL ``` This also helps to solve some of the issues in #342 Signed-off-by: Pascal Bach <pascal.bach@siemens.com> Signed-off-by: Fabio Huser <fabio.huser@siemens.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
index f3394910c5b..1e98280d045 100644
--- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
@@ -427,6 +427,45 @@ module Ci
end
end
+ describe "YAML Alias/Anchor" do
+ it "is correctly supported for jobs" do
+ config = <<EOT
+job1: &JOBTMPL
+ script: execute-script-for-job
+
+job2: *JOBTMPL
+EOT
+
+ config_processor = GitlabCiYamlProcessor.new(config)
+
+ expect(config_processor.builds_for_stage_and_ref("test", "master").size).to eq(2)
+ expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
+ except: nil,
+ stage: "test",
+ stage_idx: 1,
+ name: :job1,
+ only: nil,
+ commands: "\nexecute-script-for-job",
+ tag_list: [],
+ options: {},
+ when: "on_success",
+ allow_failure: false
+ })
+ expect(config_processor.builds_for_stage_and_ref("test", "master").second).to eq({
+ except: nil,
+ stage: "test",
+ stage_idx: 1,
+ name: :job2,
+ only: nil,
+ commands: "\nexecute-script-for-job",
+ tag_list: [],
+ options: {},
+ when: "on_success",
+ allow_failure: false
+ })
+ end
+ end
+
describe "Error handling" do
it "fails to parse YAML" do
expect{GitlabCiYamlProcessor.new("invalid: yaml: test")}.to raise_error(Psych::SyntaxError)