Read about our upcoming Code of Conduct on this issue

skip.rb 812 Bytes
Newer Older
1
2
3
4
5
module Gitlab
  module Ci
    module Pipeline
      module Chain
        class Skip < Chain::Base
6
7
          include ::Gitlab::Utils::StrongMemoize

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
          SKIP_PATTERN = /\[(ci[ _-]skip|skip[ _-]ci)\]/i

          def perform!
            if skipped?
              @pipeline.skip if @command.save_incompleted
            end
          end

          def skipped?
            !@command.ignore_skip_ci && commit_message_skips_ci?
          end

          def break?
            skipped?
          end

          private

          def commit_message_skips_ci?
            return false unless @pipeline.git_commit_message

29
30
31
            strong_memoize(:commit_message_skips_ci) do
              !!(@pipeline.git_commit_message =~ SKIP_PATTERN)
            end
32
33
34
35
36
37
          end
        end
      end
    end
  end
end