summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaetan Semet <gaetan.semet@renault.com>2019-07-15 14:47:47 +0200
committerMatija Čupić <matteeyah@gmail.com>2019-07-17 14:43:15 +0200
commit4e814c257b74ac78a50f54ec57b1e1c7f78d43b7 (patch)
tree0d18c4f71652af5727e9e156081261c7551d072d
parent4f95a8d7f6612e8df138bd831db7f689a01ef9ca (diff)
downloadgitlab-ce-4e814c257b74ac78a50f54ec57b1e1c7f78d43b7.tar.gz
Multiple pipeline support for Build status
This allows user to specify the pipeline ID when several pipelines has been triggered on the same branch and commit. Signed-off-by: Gaetan Semet <gaetan.semet@renault.com>
-rw-r--r--changelogs/unreleased/21671-multiple-pipeline-status-api.yml5
-rw-r--r--doc/api/commits.md1
-rw-r--r--lib/api/commit_statuses.rb7
3 files changed, 12 insertions, 1 deletions
diff --git a/changelogs/unreleased/21671-multiple-pipeline-status-api.yml b/changelogs/unreleased/21671-multiple-pipeline-status-api.yml
new file mode 100644
index 00000000000..f87366803e2
--- /dev/null
+++ b/changelogs/unreleased/21671-multiple-pipeline-status-api.yml
@@ -0,0 +1,5 @@
+---
+title: Multiple pipeline support for Commit status
+merge_request: 21671
+author: Gaetan Semet
+type: changed
diff --git a/doc/api/commits.md b/doc/api/commits.md
index 6eb4c47415f..a6264897e5e 100644
--- a/doc/api/commits.md
+++ b/doc/api/commits.md
@@ -581,6 +581,7 @@ POST /projects/:id/statuses/:sha
| `target_url` | string | no | The target URL to associate with this status
| `description` | string | no | The short description of the status
| `coverage` | float | no | The total code coverage
+| `pipeline_id` | integer | no | The id of the pipeline to set status. Use in case of several pipeline on same sha.
```bash
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/17/statuses/18f3e63d05582537db6d183d9d557be09e1f90c8?state=success"
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb
index 08b4f8db8b0..61cf929bcdc 100644
--- a/lib/api/commit_statuses.rb
+++ b/lib/api/commit_statuses.rb
@@ -52,6 +52,7 @@ module API
optional :name, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"'
optional :context, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"'
optional :coverage, type: Float, desc: 'The total code coverage'
+ optional :pipeline_id, type: Integer, desc: 'An existing pipeline id, when multiple pipelines on the same commit sha have been triggered'
end
# rubocop: disable CodeReuse/ActiveRecord
post ':id/statuses/:sha' do
@@ -72,8 +73,12 @@ module API
not_found! 'References for commit' unless ref
name = params[:name] || params[:context] || 'default'
+ pipeline = if params[:pipeline_id]
+ @project.ci_pipelines.find_by(id: params[:pipeline_id])
+ else
+ @project.pipeline_for(ref, commit.sha)
+ end
- pipeline = @project.pipeline_for(ref, commit.sha)
unless pipeline
pipeline = @project.ci_pipelines.create!(
source: :external,