summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2018-07-18 14:57:08 -0700
committerRobert Speicher <rspeicher@gmail.com>2018-07-18 15:04:45 -0700
commit6cb52964a6c0b64d422b4618c116a4ff9d044b67 (patch)
tree5559f18a9e396ce1021cc80b6a91c83a56a6f3b7
parent1df32177a8dfd0f1f948a48ee9cf87ba74f43417 (diff)
downloadgitlab-ce-rs-web_url-for-pipelines-and-jobs.tar.gz
Expose web_url attribute in PipelineBasic and JobBasicrs-web_url-for-pipelines-and-jobs
-rw-r--r--doc/api/jobs.md26
-rw-r--r--doc/api/pipelines.md18
-rw-r--r--lib/api/entities.rb8
-rw-r--r--spec/fixtures/api/schemas/pipeline.json4
-rw-r--r--spec/requests/api/jobs_spec.rb1
-rw-r--r--spec/requests/api/pipelines_spec.rb3
6 files changed, 45 insertions, 15 deletions
diff --git a/doc/api/jobs.md b/doc/api/jobs.md
index cfa5e9a3e95..9a950097675 100644
--- a/doc/api/jobs.md
+++ b/doc/api/jobs.md
@@ -50,6 +50,7 @@ Example of response
"started_at": "2015-12-24T17:54:24.729Z",
"status": "failed",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/6",
"user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null,
@@ -82,7 +83,7 @@ Example of response
"size": 1000
},
"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,
"name": "teaspoon",
"pipeline": {
@@ -97,6 +98,7 @@ Example of response
"started_at": "2015-12-24T17:54:27.722Z",
"status": "failed",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/7",
"user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null,
@@ -151,7 +153,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z",
"artifacts_file": null,
"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,
"name": "rspec:other",
"pipeline": {
@@ -166,6 +168,7 @@ Example of response
"started_at": "2015-12-24T17:54:24.729Z",
"status": "failed",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/6",
"user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null,
@@ -198,7 +201,7 @@ Example of response
"size": 1000
},
"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,
"name": "teaspoon",
"pipeline": {
@@ -213,6 +216,7 @@ Example of response
"started_at": "2015-12-24T17:54:27.722Z",
"status": "failed",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/7",
"user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null,
@@ -280,6 +284,7 @@ Example of response
"started_at": "2015-12-24T17:54:30.733Z",
"status": "failed",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/8",
"user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null,
@@ -455,7 +460,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null,
"finished_at": "2016-01-11T10:14:09.526Z",
- "id": 69,
+ "id": 42,
"name": "rubocop",
"ref": "master",
"runner": null,
@@ -463,6 +468,7 @@ Example of response
"started_at": null,
"status": "canceled",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null
}
```
@@ -501,7 +507,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null,
"finished_at": null,
- "id": 69,
+ "id": 42,
"name": "rubocop",
"ref": "master",
"runner": null,
@@ -509,6 +515,7 @@ Example of response
"started_at": null,
"status": "pending",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null
}
```
@@ -549,7 +556,7 @@ Example of response
},
"coverage": null,
"download_url": null,
- "id": 69,
+ "id": 42,
"name": "rubocop",
"ref": "master",
"runner": null,
@@ -559,6 +566,7 @@ Example of response
"finished_at": "2016-01-11T10:15:10.506Z",
"status": "failed",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null
}
```
@@ -599,7 +607,7 @@ Example response:
},
"coverage": null,
"download_url": null,
- "id": 69,
+ "id": 42,
"name": "rubocop",
"ref": "master",
"runner": null,
@@ -609,6 +617,7 @@ Example response:
"finished_at": "2016-01-11T10:15:10.506Z",
"status": "failed",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null
}
```
@@ -647,7 +656,7 @@ Example of response
"created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null,
"finished_at": null,
- "id": 69,
+ "id": 42,
"name": "rubocop",
"ref": "master",
"runner": null,
@@ -655,6 +664,7 @@ Example of response
"started_at": null,
"status": "started",
"tag": false,
+ "web_url": "https://example.com/foo/bar/-/jobs/42",
"user": null
}
```
diff --git a/doc/api/pipelines.md b/doc/api/pipelines.md
index 22cf9afbcd2..574be52801c 100644
--- a/doc/api/pipelines.md
+++ b/doc/api/pipelines.md
@@ -33,13 +33,15 @@ Example of response
"id": 47,
"status": "pending",
"ref": "new-pipeline",
- "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a"
+ "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
+ "web_url": "https://example.com/foo/bar/pipelines/47"
},
{
"id": 48,
"status": "pending",
"ref": "new-pipeline",
- "sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a"
+ "sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
+ "web_url": "https://example.com/foo/bar/pipelines/48"
}
]
```
@@ -86,7 +88,8 @@ Example of response
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": 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
"finished_at": null,
"committed_at": null,
"duration": null,
- "coverage": null
+ "coverage": null,
+ "web_url": "https://example.com/foo/bar/pipelines/61"
}
```
@@ -179,7 +183,8 @@ Response:
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null,
- "coverage": null
+ "coverage": null,
+ "web_url": "https://example.com/foo/bar/pipelines/46"
}
```
@@ -225,7 +230,8 @@ Response:
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null,
- "coverage": null
+ "coverage": null,
+ "web_url": "https://example.com/foo/bar/pipelines/46"
}
```
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 3f3a95ea8e6..8c40d66c651 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -529,6 +529,10 @@ module API
class PipelineBasic < Grape::Entity
expose :id, :sha, :ref, :status
+
+ expose :web_url do |pipeline, _options|
+ Gitlab::Routing.url_helpers.project_pipeline_url(pipeline.project, pipeline)
+ end
end
class MergeRequestSimple < ProjectEntity
@@ -1069,6 +1073,10 @@ module API
expose :user, with: User
expose :commit, with: Commit
expose :pipeline, with: PipelineBasic
+
+ expose :web_url do |job, _options|
+ Gitlab::Routing.url_helpers.project_job_url(job.project, job)
+ end
end
class Job < JobBasic
diff --git a/spec/fixtures/api/schemas/pipeline.json b/spec/fixtures/api/schemas/pipeline.json
index 55511d17b5e..b6e30c40f13 100644
--- a/spec/fixtures/api/schemas/pipeline.json
+++ b/spec/fixtures/api/schemas/pipeline.json
@@ -319,6 +319,10 @@
"id": "/properties/updated_at",
"type": "string"
},
+ "web_url": {
+ "id": "/properties/web_url",
+ "type": "string"
+ },
"user": {
"id": "/properties/user",
"properties": {
diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb
index 7d1a5c12805..8412d0383f7 100644
--- a/spec/requests/api/jobs_spec.rb
+++ b/spec/requests/api/jobs_spec.rb
@@ -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['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
expect(json_response['duration']).to eq(job.duration)
+ expect(json_response['web_url']).to be_present
end
it 'returns pipeline data' do
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb
index e2ca27f5d41..342a97b6a69 100644
--- a/spec/requests/api/pipelines_spec.rb
+++ b/spec/requests/api/pipelines_spec.rb
@@ -24,7 +24,8 @@ describe API::Pipelines do
expect(json_response).to be_an Array
expect(json_response.first['sha']).to match /\A\h{40}\z/
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
context 'when parameter is passed' do