Welcome to mirror list, hosted at ThFree Co, Russian Federation.

process_build_service.rb « ci « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 22cd267806d20c4fc8ace685d70990fb487baaeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

module Ci
  class ProcessBuildService < BaseService
    def execute(build, current_status)
      if valid_statuses_for_build(build).include?(current_status)
        process(build)
        true
      else
        build.skip
        false
      end
    end

    private

    def process(build)
      if build.schedulable?
        build.schedule
      elsif build.action?
        build.actionize
      else
        enqueue(build)
      end
    end

    def enqueue(build)
      return build.drop!(:failed_outdated_deployment_job) if build.prevent_rollback_deployment?

      build.enqueue
    end

    def valid_statuses_for_build(build)
      case build.when
      when 'on_success', 'manual', 'delayed'
        build.scheduling_type_dag? ? %w[success] : %w[success skipped]
      when 'on_failure'
        %w[failed]
      when 'always'
        %w[success failed skipped]
      else
        []
      end
    end
  end
end

Ci::ProcessBuildService.prepend_mod_with('Ci::ProcessBuildService')