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, #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)


34
35
36
# File 'lib/gitlab/ci/pipeline/chain/validate/abilities.rb', line 34

def break?
  @pipeline.errors.any?
end

#perform!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/ci/pipeline/chain/validate/abilities.rb', line 12

def perform!
  if project.pending_delete?
    return error('Project is deleted!')
  end

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

  if project.import_in_progress?
    return error('Import in progress')
  end

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

  unless allowed_to_run_pipeline?
    error("You do not have sufficient permission to run a pipeline on '#{command.ref}'. Please select a different branch or contact your administrator for assistance.")
  end
end