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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
c3e0731d
Commit
c3e0731d
authored
Sep 05, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add case when artifacts have not existed on dependencies
parent
6e343b27
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
7 deletions
+61
-7
app/models/ci/build.rb
app/models/ci/build.rb
+15
-5
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+20
-1
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+25
-0
No files found.
app/models/ci/build.rb
View file @
c3e0731d
...
...
@@ -143,9 +143,7 @@ module Ci
end
before_transition
any
=>
[
:running
]
do
|
build
|
if
build
.
specified_dependencies?
&&
build
.
dependencies
.
empty?
raise
MissingDependenciesError
end
build
.
validates_dependencies!
end
end
...
...
@@ -486,8 +484,20 @@ module Ci
options
[
:dependencies
]
&
.
empty?
end
def
specified_dependencies?
options
.
has_key?
(
:dependencies
)
&&
options
[
:dependencies
].
any?
def
validates_dependencies!
dependencies
.
tap
do
|
deps
|
# When `dependencies` keyword is given and depended jobs are skipped by `only` keyword
if
options
[
:dependencies
]
&
.
any?
&&
deps
.
empty?
raise
MissingDependenciesError
end
# When artifacts of depended jobs have not existsed
deps
.
each
do
|
dep
|
if
dep
.
options
[
:artifacts
]
&
.
any?
&&
!
dep
.
artifacts?
raise
MissingDependenciesError
end
end
end
end
def
hide_secrets
(
trace
)
...
...
doc/ci/yaml/README.md
View file @
c3e0731d
...
...
@@ -1107,7 +1107,7 @@ To use this feature, define `dependencies` in context of the job and pass
a list of all previous jobs from which the artifacts should be downloaded.
You can only define jobs from stages that are executed before the current one.
An error will be shown if you define jobs from the current stage or next ones,
or there are no depended jobs in previous stages.
or there are no depended jobs
with artifacts
in previous stages.
Defining an empty array will skip downloading any artifacts for that job.
The status of the previous job is not considered when using
`dependencies`
, so
if it failed or it is a manual job that was not run, no error occurs.
...
...
spec/models/ci/build_spec.rb
View file @
c3e0731d
...
...
@@ -1887,9 +1887,28 @@ describe Ci::Build do
let
(
:options
)
{
{
dependencies:
[
'test'
]
}
}
context
'when a depended job exists'
do
let!
(
:pre_
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_
stage_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
{
build
.
run!
}.
not_to
raise_error
}
context
'when "artifacts" keyword is specified on depended job'
do
let!
(
:pre_stage_job
)
do
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
,
options:
{
artifacts:
{
paths:
[
'binaries/'
]
}
}
)
end
context
'when artifacts of depended job has existsed'
do
it
{
expect
{
build
.
run!
}.
not_to
raise_error
}
end
context
'when artifacts of depended job has not existsed'
do
before
do
pre_stage_job
.
erase_artifacts!
end
it
{
expect
{
build
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
end
end
end
context
'when depended jobs do not exist'
do
...
...
spec/services/ci/register_job_service_spec.rb
View file @
c3e0731d
...
...
@@ -291,6 +291,31 @@ module Ci
it
"picks the build"
do
expect
(
picked_job
).
to
eq
(
pending_job
)
end
context
'when "artifacts" keyword is specified on depended job'
do
let!
(
:pre_stage_job
)
do
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
name:
job_name
,
stage_idx:
0
,
options:
{
artifacts:
{
paths:
[
'binaries/'
]
}
}
)
end
context
'when artifacts of depended job has existsed'
do
it
"picks the build"
do
expect
(
picked_job
).
to
eq
(
pending_job
)
end
end
context
'when artifacts of depended job has not existsed'
do
before
do
pre_stage_job
.
erase_artifacts!
end
it
'does not pick the build and drops the build'
do
expect
(
picked_job
).
to
be_nil
expect
(
pending_job
.
reload
).
to
be_failed
expect
(
pending_job
).
to
be_missing_dependency_failure
end
end
end
end
context
'when depended jobs do not exist'
do
...
...
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