Class: Gitlab::Ci::Pipeline::Chain::Command
- Inherits:
-
Struct
- Object
- Struct
- Gitlab::Ci::Pipeline::Chain::Command
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/pipeline/chain/command.rb
Instance Attribute Summary collapse
-
#after_sha ⇒ Object
Returns the value of attribute after_sha.
-
#allow_mirror_update ⇒ Object
Returns the value of attribute allow_mirror_update.
-
#before_sha ⇒ Object
Returns the value of attribute before_sha.
-
#bridge ⇒ Object
Returns the value of attribute bridge.
-
#chat_data ⇒ Object
Returns the value of attribute chat_data.
-
#checkout_sha ⇒ Object
Returns the value of attribute checkout_sha.
-
#config_content ⇒ Object
Returns the value of attribute config_content.
-
#content ⇒ Object
Returns the value of attribute content.
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#dry_run ⇒ Object
(also: #dry_run?)
Returns the value of attribute dry_run.
-
#external_pull_request ⇒ Object
Returns the value of attribute external_pull_request.
-
#ignore_skip_ci ⇒ Object
Returns the value of attribute ignore_skip_ci.
-
#merge_request ⇒ Object
Returns the value of attribute merge_request.
-
#origin_ref ⇒ Object
Returns the value of attribute origin_ref.
-
#project ⇒ Object
Returns the value of attribute project.
-
#push_options ⇒ Object
Returns the value of attribute push_options.
-
#save_incompleted ⇒ Object
Returns the value of attribute save_incompleted.
-
#schedule ⇒ Object
Returns the value of attribute schedule.
-
#seeds_block ⇒ Object
Returns the value of attribute seeds_block.
-
#source ⇒ Object
Returns the value of attribute source.
-
#source_sha ⇒ Object
Returns the value of attribute source_sha.
-
#stage_seeds ⇒ Object
Returns the value of attribute stage_seeds.
-
#target_sha ⇒ Object
Returns the value of attribute target_sha.
-
#trigger_request ⇒ Object
Returns the value of attribute trigger_request.
-
#variables_attributes ⇒ Object
Returns the value of attribute variables_attributes.
-
#yaml_processor_result ⇒ Object
Returns the value of attribute yaml_processor_result.
Instance Method Summary collapse
- #ambiguous_ref? ⇒ Boolean
- #branch_exists? ⇒ Boolean
- #dangling_build? ⇒ Boolean
-
#initialize(**params) ⇒ Command
constructor
A new instance of Command.
- #merge_request_ref_exists? ⇒ Boolean
- #metrics ⇒ Object
- #observe_creation_duration(duration) ⇒ Object
- #observe_pipeline_size(pipeline) ⇒ Object
- #origin_sha ⇒ Object
- #parent_pipeline ⇒ Object
- #protected_ref? ⇒ Boolean
- #ref ⇒ Object
- #sha ⇒ Object
- #tag_exists? ⇒ Boolean
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_sha ⇒ Object
Returns the value of attribute after_sha
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def after_sha @after_sha end |
#allow_mirror_update ⇒ Object
Returns the value of attribute 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_sha ⇒ Object
Returns the value of attribute before_sha
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def before_sha @before_sha end |
#bridge ⇒ Object
Returns the value of attribute bridge
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def bridge @bridge end |
#chat_data ⇒ Object
Returns the value of attribute chat_data
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def chat_data @chat_data end |
#checkout_sha ⇒ Object
Returns the value of attribute checkout_sha
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def checkout_sha @checkout_sha end |
#config_content ⇒ Object
Returns the value of attribute config_content
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def config_content @config_content end |
#content ⇒ Object
Returns the value of attribute content
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def content @content end |
#current_user ⇒ Object
Returns the value of attribute current_user
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def current_user @current_user end |
#dry_run ⇒ Object Also known as: dry_run?
Returns the value of attribute dry_run
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def dry_run @dry_run end |
#external_pull_request ⇒ Object
Returns the value of attribute 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_ci ⇒ Object
Returns the value of attribute 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_request ⇒ Object
Returns the value of attribute merge_request
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def merge_request @merge_request end |
#origin_ref ⇒ Object
Returns the value of attribute origin_ref
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def origin_ref @origin_ref end |
#project ⇒ Object
Returns the value of attribute project
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def project @project end |
#push_options ⇒ Object
Returns the value of attribute push_options
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def @push_options end |
#save_incompleted ⇒ Object
Returns the value of attribute save_incompleted
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def save_incompleted @save_incompleted end |
#schedule ⇒ Object
Returns the value of attribute schedule
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def schedule @schedule end |
#seeds_block ⇒ Object
Returns the value of attribute seeds_block
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def seeds_block @seeds_block end |
#source ⇒ Object
Returns the value of attribute source
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def source @source end |
#source_sha ⇒ Object
Returns the value of attribute source_sha
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def source_sha @source_sha end |
#stage_seeds ⇒ Object
Returns the value of attribute stage_seeds
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def stage_seeds @stage_seeds end |
#target_sha ⇒ Object
Returns the value of attribute target_sha
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def target_sha @target_sha end |
#trigger_request ⇒ Object
Returns the value of attribute trigger_request
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def trigger_request @trigger_request end |
#variables_attributes ⇒ Object
Returns the value of attribute variables_attributes
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def variables_attributes @variables_attributes end |
#yaml_processor_result ⇒ Object
Returns the value of attribute 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
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
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
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
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 |
#metrics ⇒ Object
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_sha ⇒ Object
58 59 60 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 58 def origin_sha checkout_sha || after_sha end |
#parent_pipeline ⇒ Object
78 79 80 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 78 def parent_pipeline bridge&.parent_pipeline end |
#protected_ref? ⇒ 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 |
#ref ⇒ Object
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 |
#sha ⇒ Object
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
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 |