Commit 9e43582c authored by Emily Ring's avatar Emily Ring

Add project_id to pipeline REST api

Add project_id to Pipeline entity
Update associated tests and docs
parent da75cd82
---
title: Add project_id to pipeline api
merge_request: 56339
author:
type: changed
...@@ -61,6 +61,7 @@ Example of response ...@@ -61,6 +61,7 @@ Example of response
"name": "teaspoon", "name": "teaspoon",
"pipeline": { "pipeline": {
"id": 6, "id": 6,
"project_id": 1,
"ref": "master", "ref": "master",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending" "status": "pending"
...@@ -114,6 +115,7 @@ Example of response ...@@ -114,6 +115,7 @@ Example of response
"name": "rspec:other", "name": "rspec:other",
"pipeline": { "pipeline": {
"id": 6, "id": 6,
"project_id": 1,
"ref": "master", "ref": "master",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending" "status": "pending"
...@@ -193,6 +195,7 @@ Example of response ...@@ -193,6 +195,7 @@ Example of response
"name": "rspec:other", "name": "rspec:other",
"pipeline": { "pipeline": {
"id": 6, "id": 6,
"project_id": 1,
"ref": "master", "ref": "master",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending" "status": "pending"
...@@ -256,6 +259,7 @@ Example of response ...@@ -256,6 +259,7 @@ Example of response
"name": "teaspoon", "name": "teaspoon",
"pipeline": { "pipeline": {
"id": 6, "id": 6,
"project_id": 1,
"ref": "master", "ref": "master",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending" "status": "pending"
...@@ -338,6 +342,7 @@ Example of response ...@@ -338,6 +342,7 @@ Example of response
"name": "teaspoon", "name": "teaspoon",
"pipeline": { "pipeline": {
"id": 6, "id": 6,
"project_id": 1,
"ref": "master", "ref": "master",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending", "status": "pending",
...@@ -419,6 +424,7 @@ Example of response ...@@ -419,6 +424,7 @@ Example of response
"name": "rubocop", "name": "rubocop",
"pipeline": { "pipeline": {
"id": 6, "id": 6,
"project_id": 1,
"ref": "master", "ref": "master",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending" "status": "pending"
...@@ -494,6 +500,7 @@ Example of response ...@@ -494,6 +500,7 @@ Example of response
"name": "rubocop", "name": "rubocop",
"pipeline": { "pipeline": {
"id": 6, "id": 6,
"project_id": 1,
"ref": "master", "ref": "master",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending" "status": "pending"
......
...@@ -54,6 +54,7 @@ Example of response ...@@ -54,6 +54,7 @@ Example of response
[ [
{ {
"id": 47, "id": 47,
"project_id": 1,
"status": "pending", "status": "pending",
"ref": "new-pipeline", "ref": "new-pipeline",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
...@@ -63,6 +64,7 @@ Example of response ...@@ -63,6 +64,7 @@ Example of response
}, },
{ {
"id": 48, "id": 48,
"project_id": 1,
"status": "pending", "status": "pending",
"ref": "new-pipeline", "ref": "new-pipeline",
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a", "sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
...@@ -95,6 +97,7 @@ Example of response ...@@ -95,6 +97,7 @@ Example of response
```json ```json
{ {
"id": 46, "id": 46,
"project_id": 1,
"status": "success", "status": "success",
"ref": "master", "ref": "master",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
...@@ -230,6 +233,7 @@ Example of response ...@@ -230,6 +233,7 @@ Example of response
```json ```json
{ {
"id": 61, "id": 61,
"project_id": 1,
"sha": "384c444e840a515b23f21915ee5766b87068a70d", "sha": "384c444e840a515b23f21915ee5766b87068a70d",
"ref": "master", "ref": "master",
"status": "pending", "status": "pending",
...@@ -277,6 +281,7 @@ Response: ...@@ -277,6 +281,7 @@ Response:
```json ```json
{ {
"id": 46, "id": 46,
"project_id": 1,
"status": "pending", "status": "pending",
"ref": "master", "ref": "master",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
...@@ -324,6 +329,7 @@ Response: ...@@ -324,6 +329,7 @@ Response:
```json ```json
{ {
"id": 46, "id": 46,
"project_id": 1,
"status": "canceled", "status": "canceled",
"ref": "master", "ref": "master",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
......
...@@ -4,7 +4,7 @@ module API ...@@ -4,7 +4,7 @@ module API
module Entities module Entities
module Ci module Ci
class PipelineBasic < Grape::Entity class PipelineBasic < Grape::Entity
expose :id, :sha, :ref, :status expose :id, :project_id, :sha, :ref, :status
expose :created_at, :updated_at expose :created_at, :updated_at
expose :web_url do |pipeline, _options| expose :web_url do |pipeline, _options|
......
{ {
"type": "object", "type": "object",
"required": ["id", "sha", "ref", "status", "created_at", "updated_at", "web_url"], "required": ["id", "project_id", "sha", "ref", "status", "created_at", "updated_at", "web_url"],
"properties": { "properties": {
"id": { "id": {
"type": "integer" "type": "integer"
}, },
"project_id": {
"type": "integer"
},
"sha": { "sha": {
"type": "string" "type": "string"
}, },
......
...@@ -34,7 +34,7 @@ RSpec.describe API::Ci::Pipelines do ...@@ -34,7 +34,7 @@ RSpec.describe API::Ci::Pipelines do
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['web_url']).to be_present expect(json_response.first['web_url']).to be_present
expect(json_response.first.keys).to contain_exactly(*%w[id sha ref status web_url created_at updated_at]) expect(json_response.first.keys).to contain_exactly(*%w[id project_id sha ref status web_url created_at updated_at])
end end
context 'when parameter is passed' do context 'when parameter is passed' do
...@@ -350,6 +350,7 @@ RSpec.describe API::Ci::Pipelines do ...@@ -350,6 +350,7 @@ RSpec.describe API::Ci::Pipelines do
expect(json_job['pipeline']).not_to be_empty expect(json_job['pipeline']).not_to be_empty
expect(json_job['pipeline']['id']).to eq job.pipeline.id expect(json_job['pipeline']['id']).to eq job.pipeline.id
expect(json_job['pipeline']['project_id']).to eq job.pipeline.project_id
expect(json_job['pipeline']['ref']).to eq job.pipeline.ref expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
expect(json_job['pipeline']['sha']).to eq job.pipeline.sha expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
expect(json_job['pipeline']['status']).to eq job.pipeline.status expect(json_job['pipeline']['status']).to eq job.pipeline.status
...@@ -512,6 +513,7 @@ RSpec.describe API::Ci::Pipelines do ...@@ -512,6 +513,7 @@ RSpec.describe API::Ci::Pipelines do
expect(json_bridge['pipeline']).not_to be_empty expect(json_bridge['pipeline']).not_to be_empty
expect(json_bridge['pipeline']['id']).to eq bridge.pipeline.id expect(json_bridge['pipeline']['id']).to eq bridge.pipeline.id
expect(json_bridge['pipeline']['project_id']).to eq bridge.pipeline.project_id
expect(json_bridge['pipeline']['ref']).to eq bridge.pipeline.ref expect(json_bridge['pipeline']['ref']).to eq bridge.pipeline.ref
expect(json_bridge['pipeline']['sha']).to eq bridge.pipeline.sha expect(json_bridge['pipeline']['sha']).to eq bridge.pipeline.sha
expect(json_bridge['pipeline']['status']).to eq bridge.pipeline.status expect(json_bridge['pipeline']['status']).to eq bridge.pipeline.status
...@@ -522,6 +524,7 @@ RSpec.describe API::Ci::Pipelines do ...@@ -522,6 +524,7 @@ RSpec.describe API::Ci::Pipelines do
expect(json_bridge['downstream_pipeline']).not_to be_empty expect(json_bridge['downstream_pipeline']).not_to be_empty
expect(json_bridge['downstream_pipeline']['id']).to eq downstream_pipeline.id expect(json_bridge['downstream_pipeline']['id']).to eq downstream_pipeline.id
expect(json_bridge['downstream_pipeline']['project_id']).to eq downstream_pipeline.project_id
expect(json_bridge['downstream_pipeline']['ref']).to eq downstream_pipeline.ref expect(json_bridge['downstream_pipeline']['ref']).to eq downstream_pipeline.ref
expect(json_bridge['downstream_pipeline']['sha']).to eq downstream_pipeline.sha expect(json_bridge['downstream_pipeline']['sha']).to eq downstream_pipeline.sha
expect(json_bridge['downstream_pipeline']['status']).to eq downstream_pipeline.status expect(json_bridge['downstream_pipeline']['status']).to eq downstream_pipeline.status
......
...@@ -44,6 +44,7 @@ RSpec.describe API::Jobs do ...@@ -44,6 +44,7 @@ RSpec.describe API::Jobs do
it 'returns common pipeline data' do it 'returns common pipeline data' do
expect(json_response['pipeline']).not_to be_empty expect(json_response['pipeline']).not_to be_empty
expect(json_response['pipeline']['id']).to eq jobx.pipeline.id expect(json_response['pipeline']['id']).to eq jobx.pipeline.id
expect(json_response['pipeline']['project_id']).to eq jobx.pipeline.project_id
expect(json_response['pipeline']['ref']).to eq jobx.pipeline.ref expect(json_response['pipeline']['ref']).to eq jobx.pipeline.ref
expect(json_response['pipeline']['sha']).to eq jobx.pipeline.sha expect(json_response['pipeline']['sha']).to eq jobx.pipeline.sha
expect(json_response['pipeline']['status']).to eq jobx.pipeline.status expect(json_response['pipeline']['status']).to eq jobx.pipeline.status
......
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