diff --git a/changelogs/unreleased/add-allow_failure-to-job-api.yml b/changelogs/unreleased/add-allow_failure-to-job-api.yml new file mode 100644 index 00000000000..5dd2b9708c5 --- /dev/null +++ b/changelogs/unreleased/add-allow_failure-to-job-api.yml @@ -0,0 +1,5 @@ +--- +title: Add allow_failure attribute to Job API +merge_request: 28406 +author: +type: added diff --git a/doc/api/jobs.md b/doc/api/jobs.md index 877cd99723a..d51451b9c83 100644 --- a/doc/api/jobs.md +++ b/doc/api/jobs.md @@ -32,6 +32,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2015-12-24T15:51:21.727Z", "started_at": "2015-12-24T17:54:24.729Z", "finished_at": "2015-12-24T17:54:24.921Z", @@ -81,6 +82,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2015-12-24T15:51:21.802Z", "started_at": "2015-12-24T17:54:27.722Z", "finished_at": "2015-12-24T17:54:27.895Z", @@ -165,6 +167,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2015-12-24T15:51:21.727Z", "started_at": "2015-12-24T17:54:24.729Z", "finished_at": "2015-12-24T17:54:24.921Z", @@ -214,6 +217,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2015-12-24T15:51:21.802Z", "started_at": "2015-12-24T17:54:27.722Z", "finished_at": "2015-12-24T17:54:27.895Z", @@ -296,6 +300,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2015-12-24T15:51:21.880Z", "started_at": "2015-12-24T17:54:30.733Z", "finished_at": "2015-12-24T17:54:31.198Z", @@ -528,6 +533,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2016-01-11T10:13:33.506Z", "started_at": "2016-01-11T10:14:09.526Z", "finished_at": null, @@ -576,6 +582,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2016-01-11T10:13:33.506Z", "started_at": null, "finished_at": null, @@ -628,6 +635,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "download_url": null, "id": 42, "name": "rubocop", @@ -681,6 +689,7 @@ Example response: "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "download_url": null, "id": 42, "name": "rubocop", @@ -757,6 +766,7 @@ Example of response "title": "Test the CI integration." }, "coverage": null, + "allow_failure": false, "created_at": "2016-01-11T10:13:33.506Z", "started_at": null, "finished_at": null, diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 625fada4f08..1a3318fe849 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1266,7 +1266,7 @@ module API end class JobBasic < Grape::Entity - expose :id, :status, :stage, :name, :ref, :tag, :coverage + expose :id, :status, :stage, :name, :ref, :tag, :coverage, :allow_failure expose :created_at, :started_at, :finished_at expose :duration expose :user, with: User diff --git a/spec/fixtures/api/schemas/public_api/v4/job.json b/spec/fixtures/api/schemas/public_api/v4/job.json index 454935422a0..c038ae0a664 100644 --- a/spec/fixtures/api/schemas/public_api/v4/job.json +++ b/spec/fixtures/api/schemas/public_api/v4/job.json @@ -28,6 +28,7 @@ "ref": { "type": "string" }, "tag": { "type": "boolean" }, "coverage": { "type": ["number", "null"] }, + "allow_failure": { "type": "boolean" }, "created_at": { "type": "string" }, "started_at": { "type": ["null", "string"] }, "finished_at": { "type": ["null", "string"] }, diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index c14507de186..43462913497 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -286,6 +286,7 @@ describe API::Jobs do expect(json_response['ref']).to eq(job.ref) expect(json_response['tag']).to eq(job.tag) expect(json_response['coverage']).to eq(job.coverage) + expect(json_response['allow_failure']).to eq(job.allow_failure) expect(Time.parse(json_response['created_at'])).to be_like_time(job.created_at) expect(Time.parse(json_response['started_at'])).to be_like_time(job.started_at) expect(Time.parse(json_response['finished_at'])).to be_like_time(job.finished_at)