Class: Gitlab::Ci::Pipeline::Chain::Command

Inherits:
Struct
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/pipeline/chain/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(**params) ⇒ Command

Returns a new instance of Command.


19
20
21
22
23
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 19

def initialize(**params)
  params.each do |key, value|
    self[key] = value
  end
end

Instance Attribute Details

#after_shaObject

Returns the value of attribute after_sha

Returns:

  • (Object)

    the current value of after_sha


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def after_sha
  @after_sha
end

#allow_mirror_updateObject

Returns the value of attribute allow_mirror_update

Returns:

  • (Object)

    the current value of allow_mirror_update


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def allow_mirror_update
  @allow_mirror_update
end

#before_shaObject

Returns the value of attribute before_sha

Returns:

  • (Object)

    the current value of before_sha


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def before_sha
  @before_sha
end

#bridgeObject

Returns the value of attribute bridge

Returns:

  • (Object)

    the current value of bridge


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def bridge
  @bridge
end

#chat_dataObject

Returns the value of attribute chat_data

Returns:

  • (Object)

    the current value of chat_data


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def chat_data
  @chat_data
end

#checkout_shaObject

Returns the value of attribute checkout_sha

Returns:

  • (Object)

    the current value of checkout_sha


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def checkout_sha
  @checkout_sha
end

#config_contentObject

Returns the value of attribute config_content

Returns:

  • (Object)

    the current value of config_content


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def config_content
  @config_content
end

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def content
  @content
end

#current_userObject

Returns the value of attribute current_user

Returns:

  • (Object)

    the current value of current_user


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def current_user
  @current_user
end

#dry_runObject Also known as: dry_run?

Returns the value of attribute dry_run

Returns:

  • (Object)

    the current value of dry_run


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def dry_run
  @dry_run
end

#external_pull_requestObject

Returns the value of attribute external_pull_request

Returns:

  • (Object)

    the current value of external_pull_request


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def external_pull_request
  @external_pull_request
end

#ignore_skip_ciObject

Returns the value of attribute ignore_skip_ci

Returns:

  • (Object)

    the current value of ignore_skip_ci


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def ignore_skip_ci
  @ignore_skip_ci
end

#merge_requestObject

Returns the value of attribute merge_request

Returns:

  • (Object)

    the current value of merge_request


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def merge_request
  @merge_request
end

#origin_refObject

Returns the value of attribute origin_ref

Returns:

  • (Object)

    the current value of origin_ref


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def origin_ref
  @origin_ref
end

#projectObject

Returns the value of attribute project

Returns:

  • (Object)

    the current value of project


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def project
  @project
end

#push_optionsObject

Returns the value of attribute push_options

Returns:

  • (Object)

    the current value of push_options


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def push_options
  @push_options
end

#save_incompletedObject

Returns the value of attribute save_incompleted

Returns:

  • (Object)

    the current value of save_incompleted


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def save_incompleted
  @save_incompleted
end

#scheduleObject

Returns the value of attribute schedule

Returns:

  • (Object)

    the current value of schedule


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def schedule
  @schedule
end

#seeds_blockObject

Returns the value of attribute seeds_block

Returns:

  • (Object)

    the current value of seeds_block


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def seeds_block
  @seeds_block
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def source
  @source
end

#source_shaObject

Returns the value of attribute source_sha

Returns:

  • (Object)

    the current value of source_sha


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def source_sha
  @source_sha
end

#stage_seedsObject

Returns the value of attribute stage_seeds

Returns:

  • (Object)

    the current value of stage_seeds


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def stage_seeds
  @stage_seeds
end

#target_shaObject

Returns the value of attribute target_sha

Returns:

  • (Object)

    the current value of target_sha


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def target_sha
  @target_sha
end

#trigger_requestObject

Returns the value of attribute trigger_request

Returns:

  • (Object)

    the current value of trigger_request


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def trigger_request
  @trigger_request
end

#variables_attributesObject

Returns the value of attribute variables_attributes

Returns:

  • (Object)

    the current value of variables_attributes


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def variables_attributes
  @variables_attributes
end

#yaml_processor_resultObject

Returns the value of attribute yaml_processor_result

Returns:

  • (Object)

    the current value of yaml_processor_result


7
8
9
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7

def yaml_processor_result
  @yaml_processor_result
end

Instance Method Details

#ambiguous_ref?Boolean

Returns:

  • (Boolean)

72
73
74
75
76
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 72

def ambiguous_ref?
  strong_memoize(:ambiguous_ref) do
    project.repository.ambiguous_ref?(origin_ref)
  end
end

#branch_exists?Boolean

Returns:

  • (Boolean)

27
28
29
30
31
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 27

def branch_exists?
  strong_memoize(:is_branch) do
    project.repository.branch_exists?(ref)
  end
end

#dangling_build?Boolean

Returns:

  • (Boolean)

96
97
98
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 96

def dangling_build?
  %i[ondemand_dast_scan webide].include?(source)
end

#merge_request_ref_exists?Boolean

Returns:

  • (Boolean)

39
40
41
42
43
44
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 39

def merge_request_ref_exists?
  strong_memoize(:merge_request_ref_exists) do
    MergeRequest.merge_request_ref?(origin_ref) &&
      project.repository.ref_exists?(origin_ref)
  end
end

#metricsObject


82
83
84
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 82

def metrics
  @metrics ||= ::Gitlab::Ci::Pipeline::Metrics.new
end

#observe_creation_duration(duration) ⇒ Object


86
87
88
89
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 86

def observe_creation_duration(duration)
  metrics.pipeline_creation_duration_histogram
    .observe({}, duration.seconds)
end

#observe_pipeline_size(pipeline) ⇒ Object


91
92
93
94
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 91

def observe_pipeline_size(pipeline)
  metrics.pipeline_size_histogram
    .observe({ source: pipeline.source.to_s }, pipeline.total_size)
end

#origin_shaObject


58
59
60
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 58

def origin_sha
  checkout_sha || after_sha
end

#parent_pipelineObject


78
79
80
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 78

def parent_pipeline
  bridge&.parent_pipeline
end

#protected_ref?Boolean

Returns:

  • (Boolean)

66
67
68
69
70
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 66

def protected_ref?
  strong_memoize(:protected_ref) do
    project.protected_for?(origin_ref)
  end
end

#refObject


46
47
48
49
50
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 46

def ref
  strong_memoize(:ref) do
    Gitlab::Git.ref_name(origin_ref)
  end
end

#shaObject


52
53
54
55
56
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 52

def sha
  strong_memoize(:sha) do
    project.commit(origin_sha || origin_ref).try(:id)
  end
end

#tag_exists?Boolean

Returns:

  • (Boolean)

33
34
35
36
37
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 33

def tag_exists?
  strong_memoize(:is_tag) do
    project.repository.tag_exists?(ref)
  end
end