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

Constant Summary collapse

GL_BUILD_ID_KEY =
"glBuildId"

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?, #can_all?, #can_any?

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)


45
46
47
# File 'lib/gitlab/ci/pipeline/chain/validate/abilities.rb', line 45

def break?
  @pipeline.errors.any?
end

#perform!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gitlab/ci/pipeline/chain/validate/abilities.rb', line 14

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('You cannot run pipelines before project import is complete.')
  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

  if push_from_ci?
    Gitlab::AppLogger.info(
      message: "Pipeline creation blocked for CI job token push",
      build_id: command.gitaly_context[GL_BUILD_ID_KEY],
      project_id: project.id
    )
    error('Pipeline creation is not allowed when pushing from CI jobs. This prevents infinite pipeline loops.')
  end
end