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.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#merge_request ⇒ Object
Returns the value of attribute merge_request.
-
#origin_ref ⇒ Object
Returns the value of attribute origin_ref.
-
#pipeline_config ⇒ Object
Returns the value of attribute pipeline_config.
-
#pipeline_seed ⇒ Object
Returns the value of attribute pipeline_seed.
-
#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.
-
#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.
-
#workflow_rules_result ⇒ Object
Returns the value of attribute workflow_rules_result.
-
#yaml_processor_result ⇒ Object
Returns the value of attribute yaml_processor_result.
Instance Method Summary collapse
- #ambiguous_ref? ⇒ Boolean
- #branch_exists? ⇒ Boolean
- #creates_child_pipeline? ⇒ Boolean
- #increment_pipeline_failure_reason_counter(reason) ⇒ Object
-
#initialize(params = {}) ⇒ Command
constructor
A new instance of Command.
- #merge_request_ref_exists? ⇒ Boolean
- #metrics ⇒ Object
- #observe_creation_duration(duration) ⇒ Object
- #observe_jobs_count_in_alive_pipelines ⇒ Object
- #observe_pipeline_size(pipeline) ⇒ Object
- #observe_step_duration(step_class, duration) ⇒ Object
- #origin_sha ⇒ Object
- #parent_pipeline ⇒ Object
- #parent_pipeline_partition_id ⇒ Object
- #protected_ref? ⇒ Boolean
- #ref ⇒ Object
- #sha ⇒ Object
- #tag_exists? ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ Command
Returns a new instance of Command.
21 22 23 24 25 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 21 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
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def after_sha @after_sha end |
#allow_mirror_update ⇒ Object
Returns the value of attribute allow_mirror_update
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def allow_mirror_update @allow_mirror_update end |
#before_sha ⇒ Object
Returns the value of attribute before_sha
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def before_sha @before_sha end |
#bridge ⇒ Object
Returns the value of attribute bridge
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def bridge @bridge end |
#chat_data ⇒ Object
Returns the value of attribute chat_data
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def chat_data @chat_data end |
#checkout_sha ⇒ Object
Returns the value of attribute checkout_sha
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def checkout_sha @checkout_sha end |
#config_content ⇒ Object
Returns the value of attribute config_content
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def config_content @config_content end |
#content ⇒ Object
Returns the value of attribute content
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def content @content end |
#current_user ⇒ Object
Returns the value of attribute current_user
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def current_user @current_user end |
#dry_run ⇒ Object Also known as: dry_run?
Returns the value of attribute dry_run
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def dry_run @dry_run end |
#external_pull_request ⇒ Object
Returns the value of attribute external_pull_request
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def external_pull_request @external_pull_request end |
#ignore_skip_ci ⇒ Object
Returns the value of attribute ignore_skip_ci
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def ignore_skip_ci @ignore_skip_ci end |
#logger ⇒ Object
Returns the value of attribute logger
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def logger @logger end |
#merge_request ⇒ Object
Returns the value of attribute merge_request
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def merge_request @merge_request end |
#origin_ref ⇒ Object
Returns the value of attribute origin_ref
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def origin_ref @origin_ref end |
#pipeline_config ⇒ Object
Returns the value of attribute pipeline_config
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def pipeline_config @pipeline_config end |
#pipeline_seed ⇒ Object
Returns the value of attribute pipeline_seed
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def pipeline_seed @pipeline_seed end |
#project ⇒ Object
Returns the value of attribute project
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def project @project end |
#push_options ⇒ Object
Returns the value of attribute push_options
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def @push_options end |
#save_incompleted ⇒ Object
Returns the value of attribute save_incompleted
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def save_incompleted @save_incompleted end |
#schedule ⇒ Object
Returns the value of attribute schedule
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def schedule @schedule end |
#seeds_block ⇒ Object
Returns the value of attribute seeds_block
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def seeds_block @seeds_block end |
#source ⇒ Object
Returns the value of attribute source
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def source @source end |
#source_sha ⇒ Object
Returns the value of attribute source_sha
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def source_sha @source_sha end |
#target_sha ⇒ Object
Returns the value of attribute target_sha
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def target_sha @target_sha end |
#trigger_request ⇒ Object
Returns the value of attribute trigger_request
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def trigger_request @trigger_request end |
#variables_attributes ⇒ Object
Returns the value of attribute variables_attributes
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def variables_attributes @variables_attributes end |
#workflow_rules_result ⇒ Object
Returns the value of attribute workflow_rules_result
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def workflow_rules_result @workflow_rules_result end |
#yaml_processor_result ⇒ Object
Returns the value of attribute yaml_processor_result
8 9 10 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 8 def yaml_processor_result @yaml_processor_result end |
Instance Method Details
#ambiguous_ref? ⇒ Boolean
74 75 76 77 78 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 74 def ambiguous_ref? strong_memoize(:ambiguous_ref) do project.repository.ambiguous_ref?(origin_ref) end end |
#branch_exists? ⇒ Boolean
29 30 31 32 33 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 29 def branch_exists? strong_memoize(:is_branch) do branch_ref? && project.repository.branch_exists?(ref) end end |
#creates_child_pipeline? ⇒ Boolean
88 89 90 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 88 def creates_child_pipeline? bridge&.triggers_child_pipeline? end |
#increment_pipeline_failure_reason_counter(reason) ⇒ Object
131 132 133 134 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 131 def increment_pipeline_failure_reason_counter(reason) metrics.pipeline_failure_reason_counter .increment(reason: (reason || :unknown_failure).to_s) end |
#merge_request_ref_exists? ⇒ Boolean
41 42 43 44 45 46 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 41 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
92 93 94 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 92 def metrics @metrics ||= ::Gitlab::Ci::Pipeline::Metrics end |
#observe_creation_duration(duration) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 110 def observe_creation_duration(duration) logger.observe(:pipeline_creation_duration_s, duration, once: true) metrics.pipeline_creation_duration_histogram .observe({ gitlab: gitlab_org_project?.to_s }, duration.seconds) end |
#observe_jobs_count_in_alive_pipelines ⇒ Object
124 125 126 127 128 129 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 124 def observe_jobs_count_in_alive_pipelines jobs_count = project.all_pipelines.jobs_count_in_alive_pipelines metrics.active_jobs_histogram .observe({ plan: project.actual_plan_name }, jobs_count) end |
#observe_pipeline_size(pipeline) ⇒ Object
117 118 119 120 121 122 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 117 def observe_pipeline_size(pipeline) logger.observe(:pipeline_size_count, pipeline.total_size, once: true) metrics.pipeline_size_histogram .observe({ source: pipeline.source.to_s, plan: project.actual_plan_name }, pipeline.total_size) end |
#observe_step_duration(step_class, duration) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 100 def observe_step_duration(step_class, duration) step = step_class.name.underscore.parameterize(separator: '_') logger.observe("pipeline_step_#{step}_duration_s", duration, once: true) if Feature.enabled?(:ci_pipeline_creation_step_duration_tracking, type: :ops) metrics.pipeline_creation_step_duration_histogram .observe({ step: step_class.name }, duration.seconds) end end |
#origin_sha ⇒ Object
60 61 62 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 60 def origin_sha checkout_sha || after_sha end |
#parent_pipeline ⇒ Object
80 81 82 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 80 def parent_pipeline bridge&.parent_pipeline end |
#parent_pipeline_partition_id ⇒ Object
84 85 86 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 84 def parent_pipeline_partition_id parent_pipeline.partition_id if creates_child_pipeline? end |
#protected_ref? ⇒ Boolean
68 69 70 71 72 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 68 def protected_ref? strong_memoize(:protected_ref) do project.protected_for?(origin_ref) end end |
#ref ⇒ Object
48 49 50 51 52 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 48 def ref strong_memoize(:ref) do Gitlab::Git.ref_name(origin_ref) end end |
#sha ⇒ Object
54 55 56 57 58 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 54 def sha strong_memoize(:sha) do project.commit(origin_sha || origin_ref).try(:id) end end |
#tag_exists? ⇒ Boolean
35 36 37 38 39 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 35 def tag_exists? strong_memoize(:is_tag) do tag_ref? && project.repository.tag_exists?(ref) end end |