summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-09 12:47:11 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-13 15:11:21 +0100
commitffcf3c68586b5e4a977a3c92cd1b3f8b1871c322 (patch)
tree7b243e742f1eeb1589e4b7ffb3971ed88de51b34 /app
parent008f22cd820a5bf9e8ff9a68550c9550463d3279 (diff)
downloadgitlab-ce-ffcf3c68586b5e4a977a3c92cd1b3f8b1871c322.tar.gz
Skip job only when canceling the pipeline it belongs to
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb8
-rw-r--r--app/models/commit_status.rb3
2 files changed, 8 insertions, 3 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index bbc358adb83..8371c2d8c72 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -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
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 4a064644d64..9547c57b2ae 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -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|