From 4e814c257b74ac78a50f54ec57b1e1c7f78d43b7 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Mon, 15 Jul 2019 14:47:47 +0200 Subject: 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 --- lib/api/commit_statuses.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/api/commit_statuses.rb') 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, -- cgit v1.2.1 From 41b8dca877ba790cd56677dc6405e16b631f9854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Wed, 17 Jul 2019 01:36:49 +0200 Subject: Add specs for specifying pipeline behavior Adds specs for testing the new behavior of specifying a pipeline when POSTing a status. --- lib/api/commit_statuses.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/api/commit_statuses.rb') diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb index 61cf929bcdc..d58a5e214ed 100644 --- a/lib/api/commit_statuses.rb +++ b/lib/api/commit_statuses.rb @@ -52,7 +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' + 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 @@ -73,11 +73,8 @@ 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, params[:pipeline_id]) unless pipeline pipeline = @project.ci_pipelines.create!( -- cgit v1.2.1