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
7b143a40
Commit
7b143a40
authored
Dec 01, 2021
by
Albert Vaca Cintora
Committed by
Fabio Pitino
Dec 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return job failure reason in API responses
Changelog: added
parent
0b096a99
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
0 deletions
+27
-0
doc/api/job_artifacts.md
doc/api/job_artifacts.md
+1
-0
doc/api/jobs.md
doc/api/jobs.md
+5
-0
lib/api/entities/ci/job_basic.rb
lib/api/entities/ci/job_basic.rb
+1
-0
spec/requests/api/ci/jobs_spec.rb
spec/requests/api/ci/jobs_spec.rb
+20
-0
No files found.
doc/api/job_artifacts.md
View file @
7b143a40
...
...
@@ -252,6 +252,7 @@ Example response:
"finished_at"
:
"2016-01-11T10:15:10.506Z"
,
"duration"
:
97.0
,
"status"
:
"failed"
,
"failure_reason"
:
"script_failure"
,
"tag"
:
false
,
"web_url"
:
"https://example.com/foo/bar/-/jobs/42"
,
"user"
:
null
...
...
doc/api/jobs.md
View file @
7b143a40
...
...
@@ -71,6 +71,7 @@ Example of response
"runner"
:
null
,
"stage"
:
"test"
,
"status"
:
"failed"
,
"failure_reason"
:
"script_failure"
,
"tag"
:
false
,
"web_url"
:
"https://example.com/foo/bar/-/jobs/7"
,
"user"
:
{
...
...
@@ -126,6 +127,7 @@ Example of response
"runner"
:
null
,
"stage"
:
"test"
,
"status"
:
"failed"
,
"failure_reason"
:
"stuck_or_timeout_failure"
,
"tag"
:
false
,
"web_url"
:
"https://example.com/foo/bar/-/jobs/6"
,
"user"
:
{
...
...
@@ -207,6 +209,7 @@ Example of response
"runner"
:
null
,
"stage"
:
"test"
,
"status"
:
"failed"
,
"failure_reason"
:
"stuck_or_timeout_failure"
,
"tag"
:
false
,
"web_url"
:
"https://example.com/foo/bar/-/jobs/6"
,
"user"
:
{
...
...
@@ -271,6 +274,7 @@ Example of response
"runner"
:
null
,
"stage"
:
"test"
,
"status"
:
"failed"
,
"failure_reason"
:
"script_failure"
,
"tag"
:
false
,
"web_url"
:
"https://example.com/foo/bar/-/jobs/7"
,
"user"
:
{
...
...
@@ -443,6 +447,7 @@ Example of response
"runner"
:
null
,
"stage"
:
"test"
,
"status"
:
"failed"
,
"failure_reason"
:
"script_failure"
,
"tag"
:
false
,
"web_url"
:
"https://example.com/foo/bar/-/jobs/8"
,
"user"
:
{
...
...
lib/api/entities/ci/job_basic.rb
View file @
7b143a40
...
...
@@ -13,6 +13,7 @@ module API
expose
:user
,
with:
::
API
::
Entities
::
User
expose
:commit
,
with:
::
API
::
Entities
::
Commit
expose
:pipeline
,
with:
::
API
::
Entities
::
Ci
::
PipelineBasic
expose
:failure_reason
,
if:
->
(
job
)
{
job
.
failed?
}
expose
:web_url
do
|
job
,
_options
|
Gitlab
::
Routing
.
url_helpers
.
project_job_url
(
job
.
project
,
job
)
...
...
spec/requests/api/ci/jobs_spec.rb
View file @
7b143a40
...
...
@@ -428,6 +428,26 @@ RSpec.describe API::Ci::Jobs do
end
end
context
'when job succeeded'
do
it
'does not return failure_reason'
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
"
,
api_user
)
expect
(
json_response
).
not_to
include
(
'failure_reason'
)
end
end
context
'when job failed'
do
let
(
:job
)
do
create
(
:ci_build
,
:failed
,
:tags
,
pipeline:
pipeline
)
end
it
'returns failure_reason'
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
"
,
api_user
)
expect
(
json_response
).
to
include
(
'failure_reason'
)
end
end
context
'when trace artifact record exists with no stored file'
,
:skip_before_request
do
before
do
create
(
:ci_job_artifact
,
:unarchived_trace_artifact
,
job:
job
,
project:
job
.
project
)
...
...
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