2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Pipeline
|
|
|
|
module Chain
|
|
|
|
class Skip < Chain::Base
|
|
|
|
include ::Gitlab::Utils::StrongMemoize
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
SKIP_PATTERN = /\[(ci[ _-]skip|skip[ _-]ci)\]/i.freeze
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def perform!
|
|
|
|
if skipped?
|
2021-06-08 01:23:25 +05:30
|
|
|
if @command.save_incompleted
|
|
|
|
# Project iid must be called outside a transaction, so we ensure it is set here
|
|
|
|
# otherwise it may be set within the state transition transaction of the skip call
|
|
|
|
# which it will lock the InternalId row for the whole transaction
|
|
|
|
@pipeline.ensure_project_iid!
|
|
|
|
|
|
|
|
@pipeline.skip
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def skipped?
|
2019-02-15 15:39:39 +05:30
|
|
|
!@command.ignore_skip_ci && (commit_message_skips_ci? || push_option_skips_ci?)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def break?
|
|
|
|
skipped?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def commit_message_skips_ci?
|
|
|
|
return false unless @pipeline.git_commit_message
|
|
|
|
|
|
|
|
strong_memoize(:commit_message_skips_ci) do
|
|
|
|
!!(@pipeline.git_commit_message =~ SKIP_PATTERN)
|
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
def push_option_skips_ci?
|
2019-07-07 11:18:12 +05:30
|
|
|
@command.push_options.present? &&
|
|
|
|
@command.push_options.deep_symbolize_keys.dig(:ci, :skip).present?
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|