Skip job only when canceling the pipeline it belongs to
This commit is contained in:
parent
008f22cd82
commit
ffcf3c6858
3 changed files with 12 additions and 4 deletions
|
@ -214,7 +214,13 @@ module Ci
|
|||
def cancel_running
|
||||
Gitlab::OptimisticLocking.retry_lock(
|
||||
statuses.cancelable) do |cancelable|
|
||||
cancelable.each(&:cancel)
|
||||
cancelable.each do |status|
|
||||
if status.created?
|
||||
status.skip
|
||||
elsif status.active?
|
||||
status.cancel
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -65,8 +65,7 @@ class CommitStatus < ActiveRecord::Base
|
|||
end
|
||||
|
||||
event :cancel do
|
||||
transition [:created] => :skipped
|
||||
transition [:pending, :running] => :canceled
|
||||
transition [:created, :pending, :running] => :canceled
|
||||
end
|
||||
|
||||
before_transition created: [:pending, :running] do |commit_status|
|
||||
|
|
|
@ -5,12 +5,15 @@ describe API::CommitStatuses, api: true do
|
|||
|
||||
let!(:project) { create(:project, :repository) }
|
||||
let(:commit) { project.repository.commit }
|
||||
let(:commit_status) { create(:commit_status, pipeline: pipeline) }
|
||||
let(:guest) { create_user(:guest) }
|
||||
let(:reporter) { create_user(:reporter) }
|
||||
let(:developer) { create_user(:developer) }
|
||||
let(:sha) { commit.id }
|
||||
|
||||
let(:commit_status) do
|
||||
create(:commit_status, status: :pending, pipeline: pipeline)
|
||||
end
|
||||
|
||||
describe "GET /projects/:id/repository/commits/:sha/statuses" do
|
||||
let(:get_url) { "/projects/#{project.id}/repository/commits/#{sha}/statuses" }
|
||||
|
||||
|
|
Loading…
Reference in a new issue