debian-mirror-gitlab/app/services/ci/process_build_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
module Ci
class ProcessBuildService < BaseService
2023-05-27 22:25:52 +05:30
def execute(processable, current_status)
if valid_statuses_for_processable(processable).include?(current_status)
process(processable)
2018-12-05 23:21:45 +05:30
true
else
2023-05-27 22:25:52 +05:30
processable.skip
2018-12-05 23:21:45 +05:30
false
end
end
private
2023-05-27 22:25:52 +05:30
def process(processable)
return enqueue(processable) if processable.enqueue_immediately?
2023-01-13 00:05:48 +05:30
2023-05-27 22:25:52 +05:30
if processable.schedulable?
processable.schedule
elsif processable.action?
processable.actionize
2022-03-02 08:16:31 +05:30
else
2023-05-27 22:25:52 +05:30
enqueue(processable)
2022-03-02 08:16:31 +05:30
end
end
2023-05-27 22:25:52 +05:30
def enqueue(processable)
return processable.drop!(:failed_outdated_deployment_job) if processable.outdated_deployment?
2022-11-25 23:54:43 +05:30
2023-05-27 22:25:52 +05:30
processable.enqueue
2018-12-05 23:21:45 +05:30
end
2023-05-27 22:25:52 +05:30
def valid_statuses_for_processable(processable)
case processable.when
2021-03-08 18:12:59 +05:30
when 'on_success', 'manual', 'delayed'
2023-05-27 22:25:52 +05:30
processable.scheduling_type_dag? ? %w[success] : %w[success skipped]
2021-03-08 18:12:59 +05:30
when 'on_failure'
%w[failed]
when 'always'
%w[success failed skipped]
else
[]
end
end
2018-12-05 23:21:45 +05:30
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Ci::ProcessBuildService.prepend_mod_with('Ci::ProcessBuildService')