Commit 480b5345 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'rs-web_url-for-pipelines-and-jobs' into 'master'

Expose web_url attribute in PipelineBasic and JobBasic

See merge request gitlab-org/gitlab-ce!20703
parents 8bc7845f 0f02ce35
...@@ -50,6 +50,7 @@ Example of response ...@@ -50,6 +50,7 @@ Example of response
"started_at": "2015-12-24T17:54:24.729Z", "started_at": "2015-12-24T17:54:24.729Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/6",
"user": { "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null, "bio": null,
...@@ -82,7 +83,7 @@ Example of response ...@@ -82,7 +83,7 @@ Example of response
"size": 1000 "size": 1000
}, },
"finished_at": "2015-12-24T17:54:27.895Z", "finished_at": "2015-12-24T17:54:27.895Z",
"artifacts_expire_at": "2016-01-23T17:54:27.895Z" "artifacts_expire_at": "2016-01-23T17:54:27.895Z",
"id": 7, "id": 7,
"name": "teaspoon", "name": "teaspoon",
"pipeline": { "pipeline": {
...@@ -97,6 +98,7 @@ Example of response ...@@ -97,6 +98,7 @@ Example of response
"started_at": "2015-12-24T17:54:27.722Z", "started_at": "2015-12-24T17:54:27.722Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/7",
"user": { "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null, "bio": null,
...@@ -151,7 +153,7 @@ Example of response ...@@ -151,7 +153,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z", "created_at": "2015-12-24T15:51:21.727Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": "2015-12-24T17:54:24.921Z", "finished_at": "2015-12-24T17:54:24.921Z",
"artifacts_expire_at": "2016-01-23T17:54:24.921Z" "artifacts_expire_at": "2016-01-23T17:54:24.921Z",
"id": 6, "id": 6,
"name": "rspec:other", "name": "rspec:other",
"pipeline": { "pipeline": {
...@@ -166,6 +168,7 @@ Example of response ...@@ -166,6 +168,7 @@ Example of response
"started_at": "2015-12-24T17:54:24.729Z", "started_at": "2015-12-24T17:54:24.729Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/6",
"user": { "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null, "bio": null,
...@@ -198,7 +201,7 @@ Example of response ...@@ -198,7 +201,7 @@ Example of response
"size": 1000 "size": 1000
}, },
"finished_at": "2015-12-24T17:54:27.895Z", "finished_at": "2015-12-24T17:54:27.895Z",
"artifacts_expire_at": "2016-01-23T17:54:27.895Z" "artifacts_expire_at": "2016-01-23T17:54:27.895Z",
"id": 7, "id": 7,
"name": "teaspoon", "name": "teaspoon",
"pipeline": { "pipeline": {
...@@ -213,6 +216,7 @@ Example of response ...@@ -213,6 +216,7 @@ Example of response
"started_at": "2015-12-24T17:54:27.722Z", "started_at": "2015-12-24T17:54:27.722Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/7",
"user": { "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null, "bio": null,
...@@ -280,6 +284,7 @@ Example of response ...@@ -280,6 +284,7 @@ Example of response
"started_at": "2015-12-24T17:54:30.733Z", "started_at": "2015-12-24T17:54:30.733Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/8",
"user": { "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null, "bio": null,
...@@ -455,7 +460,7 @@ Example of response ...@@ -455,7 +460,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z", "created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": "2016-01-11T10:14:09.526Z", "finished_at": "2016-01-11T10:14:09.526Z",
"id": 69, "id": 42,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
...@@ -463,6 +468,7 @@ Example of response ...@@ -463,6 +468,7 @@ Example of response
"started_at": null, "started_at": null,
"status": "canceled", "status": "canceled",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null "user": null
} }
``` ```
...@@ -501,7 +507,7 @@ Example of response ...@@ -501,7 +507,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z", "created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": null, "finished_at": null,
"id": 69, "id": 42,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
...@@ -509,6 +515,7 @@ Example of response ...@@ -509,6 +515,7 @@ Example of response
"started_at": null, "started_at": null,
"status": "pending", "status": "pending",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null "user": null
} }
``` ```
...@@ -549,7 +556,7 @@ Example of response ...@@ -549,7 +556,7 @@ Example of response
}, },
"coverage": null, "coverage": null,
"download_url": null, "download_url": null,
"id": 69, "id": 42,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
...@@ -559,6 +566,7 @@ Example of response ...@@ -559,6 +566,7 @@ Example of response
"finished_at": "2016-01-11T10:15:10.506Z", "finished_at": "2016-01-11T10:15:10.506Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null "user": null
} }
``` ```
...@@ -599,7 +607,7 @@ Example response: ...@@ -599,7 +607,7 @@ Example response:
}, },
"coverage": null, "coverage": null,
"download_url": null, "download_url": null,
"id": 69, "id": 42,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
...@@ -609,6 +617,7 @@ Example response: ...@@ -609,6 +617,7 @@ Example response:
"finished_at": "2016-01-11T10:15:10.506Z", "finished_at": "2016-01-11T10:15:10.506Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null "user": null
} }
``` ```
...@@ -647,7 +656,7 @@ Example of response ...@@ -647,7 +656,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z", "created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": null, "finished_at": null,
"id": 69, "id": 42,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
...@@ -655,6 +664,7 @@ Example of response ...@@ -655,6 +664,7 @@ Example of response
"started_at": null, "started_at": null,
"status": "started", "status": "started",
"tag": false, "tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null "user": null
} }
``` ```
...@@ -33,13 +33,15 @@ Example of response ...@@ -33,13 +33,15 @@ Example of response
"id": 47, "id": 47,
"status": "pending", "status": "pending",
"ref": "new-pipeline", "ref": "new-pipeline",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a" "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"web_url": "https://example.com/foo/bar/pipelines/47"
}, },
{ {
"id": 48, "id": 48,
"status": "pending", "status": "pending",
"ref": "new-pipeline", "ref": "new-pipeline",
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a" "sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
"web_url": "https://example.com/foo/bar/pipelines/48"
} }
] ]
``` ```
...@@ -86,7 +88,8 @@ Example of response ...@@ -86,7 +88,8 @@ Example of response
"finished_at": "2016-08-11T11:32:35.145Z", "finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null, "committed_at": null,
"duration": null, "duration": null,
"coverage": "30.0" "coverage": "30.0",
"web_url": "https://example.com/foo/bar/pipelines/46"
} }
``` ```
...@@ -133,7 +136,8 @@ Example of response ...@@ -133,7 +136,8 @@ Example of response
"finished_at": null, "finished_at": null,
"committed_at": null, "committed_at": null,
"duration": null, "duration": null,
"coverage": null "coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/61"
} }
``` ```
...@@ -179,7 +183,8 @@ Response: ...@@ -179,7 +183,8 @@ Response:
"finished_at": "2016-08-11T11:32:35.145Z", "finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null, "committed_at": null,
"duration": null, "duration": null,
"coverage": null "coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46"
} }
``` ```
...@@ -225,7 +230,8 @@ Response: ...@@ -225,7 +230,8 @@ Response:
"finished_at": "2016-08-11T11:32:35.145Z", "finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null, "committed_at": null,
"duration": null, "duration": null,
"coverage": null "coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46"
} }
``` ```
......
...@@ -529,6 +529,10 @@ module API ...@@ -529,6 +529,10 @@ module API
class PipelineBasic < Grape::Entity class PipelineBasic < Grape::Entity
expose :id, :sha, :ref, :status expose :id, :sha, :ref, :status
expose :web_url do |pipeline, _options|
Gitlab::Routing.url_helpers.project_pipeline_url(pipeline.project, pipeline)
end
end end
class MergeRequestSimple < ProjectEntity class MergeRequestSimple < ProjectEntity
...@@ -1069,6 +1073,10 @@ module API ...@@ -1069,6 +1073,10 @@ module API
expose :user, with: User expose :user, with: User
expose :commit, with: Commit expose :commit, with: Commit
expose :pipeline, with: PipelineBasic expose :pipeline, with: PipelineBasic
expose :web_url do |job, _options|
Gitlab::Routing.url_helpers.project_job_url(job.project, job)
end
end end
class Job < JobBasic class Job < JobBasic
......
...@@ -54,7 +54,7 @@ module API ...@@ -54,7 +54,7 @@ module API
pipeline = user_project.pipelines.find(params[:pipeline_id]) pipeline = user_project.pipelines.find(params[:pipeline_id])
builds = pipeline.builds builds = pipeline.builds
builds = filter_builds(builds, params[:scope]) builds = filter_builds(builds, params[:scope])
builds = builds.preload(:job_artifacts_archive) builds = builds.preload(:job_artifacts_archive, project: [:namespace])
present paginate(builds), with: Entities::Job present paginate(builds), with: Entities::Job
end end
......
...@@ -319,6 +319,10 @@ ...@@ -319,6 +319,10 @@
"id": "/properties/updated_at", "id": "/properties/updated_at",
"type": "string" "type": "string"
}, },
"web_url": {
"id": "/properties/web_url",
"type": "string"
},
"user": { "user": {
"id": "/properties/user", "id": "/properties/user",
"properties": { "properties": {
......
...@@ -4,13 +4,15 @@ ...@@ -4,13 +4,15 @@
"id", "id",
"sha", "sha",
"ref", "ref",
"status" "status",
"web_url"
], ],
"properties" : { "properties" : {
"id": { "type": "integer" }, "id": { "type": "integer" },
"sha": { "type": "string" }, "sha": { "type": "string" },
"ref": { "type": "string" }, "ref": { "type": "string" },
"status": { "type": "string" } "status": { "type": "string" },
"web_url": { "type": "string" }
}, },
"additionalProperties": false "additionalProperties": false
} }
...@@ -220,6 +220,7 @@ describe API::Jobs do ...@@ -220,6 +220,7 @@ describe API::Jobs do
expect(Time.parse(json_response['finished_at'])).to be_like_time(job.finished_at) expect(Time.parse(json_response['finished_at'])).to be_like_time(job.finished_at)
expect(Time.parse(json_response['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at) expect(Time.parse(json_response['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
expect(json_response['duration']).to eq(job.duration) expect(json_response['duration']).to eq(job.duration)
expect(json_response['web_url']).to be_present
end end
it 'returns pipeline data' do it 'returns pipeline data' do
......
...@@ -24,7 +24,8 @@ describe API::Pipelines do ...@@ -24,7 +24,8 @@ describe API::Pipelines do
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['sha']).to match /\A\h{40}\z/ expect(json_response.first['sha']).to match /\A\h{40}\z/
expect(json_response.first['id']).to eq pipeline.id expect(json_response.first['id']).to eq pipeline.id
expect(json_response.first.keys).to contain_exactly(*%w[id sha ref status]) expect(json_response.first['web_url']).to be_present
expect(json_response.first.keys).to contain_exactly(*%w[id sha ref status web_url])
end end
context 'when parameter is passed' do context 'when parameter is passed' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment