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
68f6c61c
Commit
68f6c61c
authored
Sep 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Allow runner API to pass failure_reason
- Fix spec
parent
1d7c0390
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
10 deletions
+29
-10
app/models/commit_status.rb
app/models/commit_status.rb
+1
-1
changelogs/unreleased/feature-sm-37239-implement-failure_reason-on-ci_builds.yml
...eature-sm-37239-implement-failure_reason-on-ci_builds.yml
+5
-0
lib/api/runner.rb
lib/api/runner.rb
+7
-1
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+4
-6
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+1
-1
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+9
-0
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+1
-1
No files found.
app/models/commit_status.rb
View file @
68f6c61c
...
...
@@ -42,7 +42,7 @@ class CommitStatus < ActiveRecord::Base
unknown_failure:
nil
,
job_failure:
1
,
api_failure:
2
,
stuck_or_timeout_failure:
3
,
stuck_or_timeout_failure:
3
}
state_machine
:status
do
...
...
changelogs/unreleased/feature-sm-37239-implement-failure_reason-on-ci_builds.yml
0 → 100644
View file @
68f6c61c
---
title
:
Implement `failure_reason` on `ci_builds`
merge_request
:
13937
author
:
type
:
added
lib/api/runner.rb
View file @
68f6c61c
...
...
@@ -114,6 +114,8 @@ module API
requires
:id
,
type:
Integer
,
desc:
%q(Job's ID)
optional
:trace
,
type:
String
,
desc:
%q(Job's full trace)
optional
:state
,
type:
String
,
desc:
%q(Job's status: success, failed)
optional
:failure_reason
,
type:
String
,
values:
CommitStatus
.
failure_reasons
.
keys
,
desc:
%q(Job's failure_reason)
end
put
'/:id'
do
job
=
authenticate_job!
...
...
@@ -127,7 +129,11 @@ module API
when
'success'
job
.
success
when
'failed'
job
.
drop
(
:job_failure
)
if
params
[
:failure_reason
]
job
.
drop
(
params
[
:failure_reason
].
to_sym
)
else
job
.
drop
(
:job_failure
)
end
end
end
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
68f6c61c
...
...
@@ -278,6 +278,7 @@ CommitStatus:
-
auto_canceled_by_id
-
retried
-
protected
-
failure_reason
Ci::Variable:
-
id
-
project_id
...
...
spec/models/commit_status_spec.rb
View file @
68f6c61c
...
...
@@ -445,22 +445,20 @@ describe CommitStatus do
end
describe
'set failure_reason when drop'
do
let
(
:
build
)
{
create
(
:ci_build
,
:created
)
}
let
(
:
commit_status
)
{
create
(
:commit_status
,
:created
)
}
before
do
build
.
drop!
(
reason
)
end
subject
{
commit_status
.
drop!
(
reason
);
commit_status
}
context
'when failure_reason is nil'
do
let
(
:reason
)
{
}
it
{
expect
(
build
)
.
to
be_unknown_failure
}
it
{
is_expected
.
to
be_unknown_failure
}
end
context
'when failure_reason is job_failure'
do
let
(
:reason
)
{
:job_failure
}
it
{
expect
(
build
)
.
to
be_job_failure
}
it
{
is_expected
.
to
be_job_failure
}
end
end
end
spec/requests/api/commit_statuses_spec.rb
View file @
68f6c61c
...
...
@@ -143,7 +143,7 @@ describe API::CommitStatuses do
expect
(
json_response
[
'target_url'
]).
to
be_nil
expect
(
json_response
[
'description'
]).
to
be_nil
if
status
==
'failed'
expect
(
CommitStatus
.
find
(
json_response
[
'id'
])).
to
be_api_failure
expect
(
json_response
[
'failure_reason'
]).
to
eq
(
'api_failure'
)
end
end
end
...
...
spec/requests/api/runner_spec.rb
View file @
68f6c61c
...
...
@@ -636,6 +636,15 @@ describe API::Runner do
expect
(
job
.
reload
.
status
).
to
eq
'failed'
expect
(
job
).
to
be_job_failure
end
context
'when failure_reason is given'
do
it
'mark job as failed'
do
update_job
(
state:
'failed'
,
failure_reason:
'stuck_or_timeout_failure'
)
expect
(
job
.
reload
.
status
).
to
eq
'failed'
expect
(
job
).
to
be_stuck_or_timeout_failure
end
end
end
context
'when tace is given'
do
...
...
spec/services/ci/retry_build_service_spec.rb
View file @
68f6c61c
...
...
@@ -22,7 +22,7 @@ describe Ci::RetryBuildService do
%i[type lock_version target_url base_tags
commit_id deployments erased_by_id last_deployment project_id
runner_id tag_taggings taggings tags trigger_request_id
user_id auto_canceled_by_id retried]
.
freeze
user_id auto_canceled_by_id retried
failure_reason
]
.
freeze
shared_examples
'build duplication'
do
let
(
:stage
)
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