Skip to content
Snippets Groups Projects
Commit 195f3102 authored by Lennard Sprong's avatar Lennard Sprong
Browse files

Return job erase date in API responses

Changelog: added
parent 4cd70424
No related branches found
No related tags found
1 merge request!109413Expose erased_at in job API
......@@ -44,6 +44,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.802Z",
"started_at": "2015-12-24T17:54:27.722Z",
"finished_at": "2015-12-24T17:54:27.895Z",
"erased_at": null,
"duration": 0.173,
"queued_duration": 0.010,
"artifacts_file": {
......@@ -112,6 +113,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z",
"started_at": "2015-12-24T17:54:24.729Z",
"finished_at": "2015-12-24T17:54:24.921Z",
"erased_at": null,
"duration": 0.192,
"queued_duration": 0.023,
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
......@@ -199,6 +201,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z",
"started_at": "2015-12-24T17:54:24.729Z",
"finished_at": "2015-12-24T17:54:24.921Z",
"erased_at": null,
"duration": 0.192,
"queued_duration": 0.023,
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
......@@ -258,6 +261,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.802Z",
"started_at": "2015-12-24T17:54:27.722Z",
"finished_at": "2015-12-24T17:54:27.895Z",
"erased_at": null,
"duration": 0.173,
"queued_duration": 0.023,
"artifacts_file": {
......@@ -361,6 +365,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.802Z",
"started_at": "2015-12-24T17:54:27.722Z",
"finished_at": "2015-12-24T17:58:27.895Z",
"erased_at": null,
"duration": 240,
"queued_duration": 0.123,
"id": 7,
......@@ -449,6 +454,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.880Z",
"started_at": "2015-12-24T17:54:30.733Z",
"finished_at": "2015-12-24T17:54:31.198Z",
"erased_at": null,
"duration": 0.465,
"queued_duration": 0.123,
"artifacts_expire_at": "2016-01-23T17:54:31.198Z",
......@@ -600,6 +606,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.880Z",
"started_at": "2015-12-24T17:54:30.733Z",
"finished_at": "2015-12-24T17:54:31.198Z",
"erased_at": null,
"duration": 0.465,
"queued_duration": 0.010,
"artifacts_expire_at": "2016-01-23T17:54:31.198Z",
......@@ -704,6 +711,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": "2016-01-11T10:14:09.526Z",
"finished_at": null,
"erased_at": null,
"duration": 8,
"queued_duration": 0.010,
"id": 1,
......@@ -757,6 +765,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": null,
"finished_at": null,
"erased_at": null,
"duration": null,
"queued_duration": 0.010,
"id": 1,
......@@ -821,6 +830,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": "2016-01-11T10:13:33.506Z",
"finished_at": "2016-01-11T10:15:10.506Z",
"erased_at": "2016-01-11T11:30:19.914Z",
"duration": 97.0,
"queued_duration": 0.010,
"status": "failed",
......@@ -894,6 +904,7 @@ Example response:
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": null,
"finished_at": null,
"erased_at": null,
"duration": null,
"queued_duration": 0.010,
"id": 1,
......
......@@ -15,6 +15,7 @@ class JobBasic < Grape::Entity
expose :created_at, documentation: { type: 'dateTime', example: '2015-12-24T15:51:21.880Z' }
expose :started_at, documentation: { type: 'dateTime', example: '2015-12-24T17:54:30.733Z' }
expose :finished_at, documentation: { type: 'dateTime', example: '2015-12-24T17:54:31.198Z' }
expose :erased_at, documentation: { type: 'dateTime', example: '2015-12-24T18:00:29.728Z' }
expose :duration,
documentation: { type: 'number', format: 'float', desc: 'Time spent running', example: 0.465 }
expose :queued_duration,
......
......@@ -11,6 +11,7 @@
"created_at",
"started_at",
"finished_at",
"erased_at",
"duration",
"queued_duration",
"user",
......@@ -35,6 +36,7 @@
"created_at": { "type": "string" },
"started_at": { "type": ["null", "string"] },
"finished_at": { "type": ["null", "string"] },
"erased_at": { "type": ["null", "string"] },
"duration": { "type": ["null", "number"] },
"queued_duration": { "type": ["null", "number"] },
"user": { "$ref": "user/basic.json" },
......
......@@ -126,6 +126,7 @@ def perform_request
it 'returns specific job data' do
expect(json_response['finished_at']).to be_nil
expect(json_response['erased_at']).to be_nil
end
it 'avoids N+1 queries', :skip_before_request do
......@@ -651,6 +652,18 @@ def go
end
end
context 'when job is erased' do
let(:job) do
create(:ci_build, pipeline: pipeline, erased_at: Time.now)
end
it 'returns specific job data' do
get api("/projects/#{project.id}/jobs/#{job.id}", api_user)
expect(Time.parse(json_response['erased_at'])).to be_like_time(job.erased_at)
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment