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
1aa37265
Commit
1aa37265
authored
Dec 18, 2021
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate against duplicates in job needs
Changelog: fixed
parent
f8495767
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+8
-0
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+6
-0
No files found.
lib/gitlab/ci/yaml_processor.rb
View file @
1aa37265
...
...
@@ -86,11 +86,19 @@ module Gitlab
def
validate_job_needs!
(
name
,
job
)
return
unless
needs
=
job
.
dig
(
:needs
,
:job
)
validate_duplicate_needs!
(
name
,
needs
)
needs
.
each
do
|
need
|
validate_job_dependency!
(
name
,
need
[
:name
],
'need'
)
end
end
def
validate_duplicate_needs!
(
name
,
needs
)
unless
needs
.
uniq
==
needs
error!
(
"
#{
name
}
has duplicate entries in the needs section."
)
end
end
def
validate_job_dependency!
(
name
,
dependency
,
dependency_type
=
'dependency'
)
unless
@jobs
[
dependency
.
to_sym
]
error!
(
"
#{
name
}
job: undefined
#{
dependency_type
}
:
#{
dependency
}
"
)
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
1aa37265
...
...
@@ -2097,6 +2097,12 @@ module Gitlab
it_behaves_like
'returns errors'
,
'test1 job: need deploy is not defined in current or prior stages'
end
context
'duplicate needs'
do
let
(
:needs
)
{
%w(build1 build1)
}
it_behaves_like
'returns errors'
,
'test1 has duplicate entries in the needs section.'
end
context
'needs and dependencies that are mismatching'
do
let
(
:needs
)
{
%w(build1)
}
let
(
:dependencies
)
{
%w(build2)
}
...
...
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