Class: Gitlab::Ci::Pipeline::Chain::Validate::Abilities

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

Instance Attribute Summary

Attributes inherited from Base

#command, #config, #pipeline

Instance Method Summary collapse

Methods included from Helpers

#error, #persist_pipeline?, #warning

Methods included from Allowable

#can?

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)

26
27
28
# File 'lib/gitlab/ci/pipeline/chain/validate/abilities.rb', line 26

def break?
  @pipeline.errors.any?
end

#perform!Object


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/ci/pipeline/chain/validate/abilities.rb', line 12

def perform!
  unless project.builds_enabled?
    return error('Pipelines are disabled!')
  end

  unless allowed_to_create_pipeline?
    return error('Insufficient permissions to create a new pipeline')
  end

  unless allowed_to_write_ref?
    error("Insufficient permissions for protected ref '#{command.ref}'")
  end
end