Class: Gitlab::Ci::Pipeline::Chain::Validate::External

Inherits:
Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/gitlab/ci/pipeline/chain/validate/external.rb

Constant Summary collapse

InvalidResponseCode =
Class.new(StandardError)
VALIDATION_REQUEST_TIMEOUT =
5

Instance Attribute Summary

Attributes inherited from Base

#command, #config, #pipeline

Instance Method Summary collapse

Methods included from Helpers

#error, #persist_pipeline?, #warning

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Ci::Pipeline::Chain::Base

Instance Method Details

#break?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/gitlab/ci/pipeline/chain/validate/external.rb', line 24

def break?
  @pipeline.errors.any?
end

#perform!Object


15
16
17
18
19
20
21
22
# File 'lib/gitlab/ci/pipeline/chain/validate/external.rb', line 15

def perform!
  pipeline_authorized = validate_external

  log_message = pipeline_authorized ? 'authorized' : 'not authorized'
  Gitlab::AppLogger.info(message: "Pipeline #{log_message}", project_id: @pipeline.project.id, user_id: @pipeline.user.id)

  error('External validation failed', drop_reason: :external_validation_failure) unless pipeline_authorized
end