summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/chain/validate_config.rb
blob: 0dba87314381e8db5d2acc8f5597b7a0f2388c93 (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
module Gitlab
  module Ci
    module Pipeline
      module Chain
        class ValidateConfig < Chain::Base
          include Chain::Helpers

          def perform!
            unless @pipeline.config_processor
              unless @pipeline.ci_yaml_file
                return error("Missing #{@pipeline.ci_yaml_file_path} file")
              end

              if @command.save_incompleted && @pipeline.has_yaml_errors?
                @pipeline.drop
              end

              return error(@pipeline.yaml_errors)
            end

            unless @pipeline.has_stage_seeds?
              return error('No stages / jobs for this pipeline.')
            end
          end

          def break?
            @pipeline.errors.any? || @pipeline.persisted?
          end
        end
      end
    end
  end
end