Commit 22e00b08 authored by Shinya Maeda's avatar Shinya Maeda Committed by Alessio Caiazza

Make schedule and unschedule consistent

parent e265fc3e
...@@ -187,7 +187,7 @@ module Ci ...@@ -187,7 +187,7 @@ module Ci
after_transition any => [:manual] do |build| after_transition any => [:manual] do |build|
build.run_after_commit do build.run_after_commit do
build.schedule build.schedule!
end end
end end
...@@ -241,17 +241,17 @@ module Ci ...@@ -241,17 +241,17 @@ module Ci
end end
def scheduled? def scheduled?
build.build_schedule.exist? build_schedule.present?
end end
def schedule def schedule!
return unless schedulable? return unless schedulable?
create_build_schedule!(execute_at: execute_at) create_build_schedule!(execute_at: execute_at)
end end
def unschedule def unschedule!
build&.build_schedule&.delete build_schedule.delete!
end end
def execute_at def execute_at
......
...@@ -7,13 +7,10 @@ module Ci ...@@ -7,13 +7,10 @@ module Ci
def perform(build_id) def perform(build_id)
::Ci::Build.preload(:build_schedule).find_by(id: build_id).try do |build| ::Ci::Build.preload(:build_schedule).find_by(id: build_id).try do |build|
break unless build.build_schedule.present? break unless build.scheduled?
begin build.unschedule!
Ci::PlayBuildService.new(build.project, build.user).execute(build) Ci::PlayBuildService.new(build.project, build.user).execute(build)
ensure
build.unschedule
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment