Commit 7124e5a4 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-build-dependencies' into 'master'

Fix build dependencies, when the dependency is a string

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/14485

See merge request !3344
parents b6806d0c 68c0dc1f
...@@ -6,6 +6,7 @@ v 8.7.0 (unreleased) ...@@ -6,6 +6,7 @@ v 8.7.0 (unreleased)
v 8.6.1 (unreleased) v 8.6.1 (unreleased)
- Do not allow to move issue if it has not been persisted - Do not allow to move issue if it has not been persisted
- Fix an issue causing the Dashboard/Milestones page to be blank - Fix an issue causing the Dashboard/Milestones page to be blank
- Fix build dependencies, when the dependency is a string
v 8.6.0 v 8.6.0
- Add ability to move issue to another project - Add ability to move issue to another project
......
...@@ -242,9 +242,9 @@ module Ci ...@@ -242,9 +242,9 @@ module Ci
stage_index = stages.index(job[:stage]) stage_index = stages.index(job[:stage])
job[:dependencies].each do |dependency| job[:dependencies].each do |dependency|
raise ValidationError, "#{name} job: undefined dependency: #{dependency}" unless @jobs[dependency] raise ValidationError, "#{name} job: undefined dependency: #{dependency}" unless @jobs[dependency.to_sym]
unless stages.index(@jobs[dependency][:stage]) < stage_index unless stages.index(@jobs[dependency.to_sym][:stage]) < stage_index
raise ValidationError, "#{name} job: dependency #{dependency} is not defined in prior stages" raise ValidationError, "#{name} job: dependency #{dependency} is not defined in prior stages"
end end
end end
......
...@@ -492,19 +492,25 @@ module Ci ...@@ -492,19 +492,25 @@ module Ci
end end
context 'dependencies to builds' do context 'dependencies to builds' do
let(:dependencies) { ['build1', 'build2'] }
it { expect { subject }.to_not raise_error }
end
context 'dependencies to builds defined as symbols' do
let(:dependencies) { [:build1, :build2] } let(:dependencies) { [:build1, :build2] }
it { expect { subject }.to_not raise_error } it { expect { subject }.to_not raise_error }
end end
context 'undefined dependency' do context 'undefined dependency' do
let(:dependencies) { [:undefined] } let(:dependencies) { ['undefined'] }
it { expect { subject }.to raise_error(GitlabCiYamlProcessor::ValidationError, 'test1 job: undefined dependency: undefined') } it { expect { subject }.to raise_error(GitlabCiYamlProcessor::ValidationError, 'test1 job: undefined dependency: undefined') }
end end
context 'dependencies to deploy' do context 'dependencies to deploy' do
let(:dependencies) { [:deploy] } let(:dependencies) { ['deploy'] }
it { expect { subject }.to raise_error(GitlabCiYamlProcessor::ValidationError, 'test1 job: dependency deploy is not defined in prior stages') } it { expect { subject }.to raise_error(GitlabCiYamlProcessor::ValidationError, 'test1 job: dependency deploy is not defined in prior stages') }
end end
......
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