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
after_transition any => [:manual] do |build|
build.run_after_commit do
build.schedule
build.schedule!
end
end
......@@ -241,17 +241,17 @@ module Ci
end
def scheduled?
build.build_schedule.exist?
build_schedule.present?
end
def schedule
def schedule!
return unless schedulable?
create_build_schedule!(execute_at: execute_at)
end
def unschedule
build&.build_schedule&.delete
def unschedule!
build_schedule.delete!
end
def execute_at
......
......@@ -7,13 +7,10 @@ module Ci
def perform(build_id)
::Ci::Build.preload(:build_schedule).find_by(id: build_id).try do |build|
break unless build.build_schedule.present?
break unless build.scheduled?
begin
Ci::PlayBuildService.new(build.project, build.user).execute(build)
ensure
build.unschedule
end
build.unschedule!
Ci::PlayBuildService.new(build.project, build.user).execute(build)
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