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
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
Show 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
...
@@ -143,9 +143,7 @@ module Ci
end
end
before_transition
any
=>
[
:running
]
do
|
build
|
before_transition
any
=>
[
:running
]
do
|
build
|
if
build
.
specified_dependencies?
&&
build
.
dependencies
.
empty?
build
.
validates_dependencies!
raise
MissingDependenciesError
end
end
end
end
end
...
@@ -486,8 +484,20 @@ module Ci
...
@@ -486,8 +484,20 @@ module Ci
options
[
:dependencies
]
&
.
empty?
options
[
:dependencies
]
&
.
empty?
end
end
def
specified_dependencies?
def
validates_dependencies!
options
.
has_key?
(
:dependencies
)
&&
options
[
:dependencies
].
any?
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
end
def
hide_secrets
(
trace
)
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
...
@@ -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.
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.
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,
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.
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
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.
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
...
@@ -1887,9 +1887,28 @@ describe Ci::Build do
let
(
:options
)
{
{
dependencies:
[
'test'
]
}
}
let
(
:options
)
{
{
dependencies:
[
'test'
]
}
}
context
'when a depended job exists'
do
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
}
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
end
context
'when depended jobs do not exist'
do
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
...
@@ -291,6 +291,31 @@ module Ci
it
"picks the build"
do
it
"picks the build"
do
expect
(
picked_job
).
to
eq
(
pending_job
)
expect
(
picked_job
).
to
eq
(
pending_job
)
end
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
end
context
'when depended jobs do not exist'
do
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