diff options
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/build.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index be4a6c553e1..6ea574ed8ec 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -186,9 +186,8 @@ module Ci end after_transition any => [:manual] do |build| - puts "#{self.class.name} - #{__callee__}: 1" build.run_after_commit do - build.schedule_delayed_execution + build.schedule end end @@ -237,22 +236,30 @@ module Ci action? && (manual? || retryable?) end - def delayed? + def schedulable? manual? && options[:start_in].present? end - def execute_at - ChronicDuration.parse(options[:start_in])&.seconds&.from_now + def scheduled? + build.build_schedule.exist? end - def schedule_delayed_execution - return unless delayed? + def schedule + return unless schedulable? create_build_schedule!(execute_at: execute_at) end + def unschedule + build&.build_schedule&.delete + end + + def execute_at + ChronicDuration.parse(options[:start_in])&.seconds&.from_now + end + def action? - self.when == 'manual' || self.when == 'delayed' + %w[manual delayed].include?(self.when) end # rubocop: disable CodeReuse/ServiceClass |