Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2d2ff9dc
Commit
2d2ff9dc
authored
Feb 11, 2022
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add error for cross pipeline dependencies
Changelog: fixed
parent
951bfb8a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+5
-3
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+21
-3
No files found.
lib/gitlab/ci/config/entry/job.rb
View file @
2d2ff9dc
...
...
@@ -37,10 +37,12 @@ module Gitlab
next
unless
dependencies
.
present?
next
unless
needs_value
.
present?
if
needs_value
[
:job
].
nil?
&&
needs_value
[
:cross_dependency
].
present?
errors
.
add
(
:needs
,
"corresponding to dependencies must be from the same pipeline"
)
else
missing_needs
=
dependencies
-
needs_value
[
:job
].
pluck
(
:name
)
# rubocop:disable CodeReuse/ActiveRecord (Array#pluck)
if
missing_needs
.
any?
errors
.
add
(
:dependencies
,
"the
#{
missing_needs
.
join
(
", "
)
}
should be part of needs"
)
errors
.
add
(
:dependencies
,
"the
#{
missing_needs
.
join
(
", "
)
}
should be part of needs"
)
if
missing_needs
.
any?
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
View file @
2d2ff9dc
...
...
@@ -420,7 +420,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
end
end
context
'when has dependencies'
do
context
'when
it
has dependencies'
do
context
'that are not a array of strings'
do
let
(
:config
)
do
{
script:
'echo'
,
dependencies:
'build-job'
}
...
...
@@ -433,8 +433,8 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
end
end
context
'when has needs'
do
context
'
when have dependencies that are not subset of
needs'
do
context
'when
the job
has needs'
do
context
'
and there are dependencies that are not included in
needs'
do
let
(
:config
)
do
{
stage:
'test'
,
...
...
@@ -448,6 +448,24 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job dependencies the another-job should be part of needs'
end
context
'and they are only cross pipeline needs'
do
let
(
:config
)
do
{
script:
'echo'
,
dependencies:
[
'rspec'
],
needs:
[{
job:
'rspec'
,
pipeline:
'other'
}]
}
end
it
'adds an error for dependency keyword usage'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job needs corresponding to dependencies must be from the same pipeline'
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment