From bc621eef541139502201884e49a03f9467ab08fc Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 31 May 2016 15:26:00 +0200 Subject: Pipelines can be canceled only when there are running builds --- app/models/ci/commit.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models/ci/commit.rb') diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index 6675a3f5d53..f22b573a94c 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -66,6 +66,10 @@ module Ci end end + def cancelable? + builds.running_or_pending.any? + end + def cancel_running builds.running_or_pending.each(&:cancel) end -- cgit v1.2.1