Skip to content
Snippets Groups Projects

Add auto-cancel for pending pipelines on branch, if they are not HEAD

All threads resolved!
Compare and Show latest version
6 files
+ 9
7
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 4
4
@@ -70,6 +70,10 @@ class Pipeline < ActiveRecord::Base
@@ -70,6 +70,10 @@ class Pipeline < ActiveRecord::Base
pipeline.update_duration
pipeline.update_duration
end
end
 
before_transition canceled: any - [:canceled] do |pipeline|
 
pipeline.auto_canceled_by = nil
 
end
 
after_transition [:created, :pending] => :running do |pipeline|
after_transition [:created, :pending] => :running do |pipeline|
pipeline.run_after_commit { PipelineMetricsWorker.perform_async(id) }
pipeline.run_after_commit { PipelineMetricsWorker.perform_async(id) }
end
end
@@ -95,10 +99,6 @@ class Pipeline < ActiveRecord::Base
@@ -95,10 +99,6 @@ class Pipeline < ActiveRecord::Base
PipelineNotificationWorker.perform_async(pipeline.id)
PipelineNotificationWorker.perform_async(pipeline.id)
end
end
end
end
after_transition :canceled => any - [:canceled] do |pipeline|
pipeline.update(auto_canceled_by: nil)
end
end
end
# ref can't be HEAD or SHA, can only be branch/tag name
# ref can't be HEAD or SHA, can only be branch/tag name
Loading