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
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.
-
#partition_id ⇒ Object
Returns the value of attribute partition_id.
-
#pipeline_config ⇒ Object
Returns the value of attribute pipeline_config.
-
#pipeline_policy_context ⇒ Object
Returns the value of attribute pipeline_policy_context.
-
#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
- #dry_run? ⇒ Boolean
- #increment_pipeline_failure_reason_counter(reason) ⇒ Object
- #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
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
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 |
#logger ⇒ Object
Returns the value of attribute logger
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def logger @logger 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 |
#partition_id ⇒ Object
Returns the value of attribute partition_id
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def partition_id @partition_id end |
#pipeline_config ⇒ Object
Returns the value of attribute pipeline_config
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def pipeline_config @pipeline_config end |
#pipeline_policy_context ⇒ Object
Returns the value of attribute pipeline_policy_context
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def pipeline_policy_context @pipeline_policy_context end |
#pipeline_seed ⇒ Object
Returns the value of attribute pipeline_seed
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def pipeline_seed @pipeline_seed 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 |
#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 |
#workflow_rules_result ⇒ Object
Returns the value of attribute workflow_rules_result
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def workflow_rules_result @workflow_rules_result 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
70 71 72 73 74 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 70 def ambiguous_ref? strong_memoize(:ambiguous_ref) do project.repository.ambiguous_ref?(origin_ref) end end |
#branch_exists? ⇒ Boolean
25 26 27 28 29 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 25 def branch_exists? strong_memoize(:is_branch) do branch_ref? && project.repository.branch_exists?(ref) end end |
#creates_child_pipeline? ⇒ Boolean
84 85 86 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 84 def creates_child_pipeline? bridge&.triggers_child_pipeline? end |
#dry_run? ⇒ Boolean
21 22 23 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 21 def dry_run? dry_run end |
#increment_pipeline_failure_reason_counter(reason) ⇒ Object
127 128 129 130 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 127 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
37 38 39 40 41 42 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 37 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
88 89 90 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 88 def metrics @metrics ||= ::Gitlab::Ci::Pipeline::Metrics end |
#observe_creation_duration(duration) ⇒ Object
106 107 108 109 110 111 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 106 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
120 121 122 123 124 125 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 120 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
113 114 115 116 117 118 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 113 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
96 97 98 99 100 101 102 103 104 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 96 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
56 57 58 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 56 def origin_sha checkout_sha || after_sha end |
#parent_pipeline ⇒ Object
76 77 78 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 76 def parent_pipeline bridge&.parent_pipeline end |
#parent_pipeline_partition_id ⇒ Object
80 81 82 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 80 def parent_pipeline_partition_id parent_pipeline.partition_id if creates_child_pipeline? end |
#protected_ref? ⇒ Boolean
64 65 66 67 68 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 64 def protected_ref? strong_memoize(:protected_ref) do project.protected_for?(origin_ref) end end |
#ref ⇒ Object
44 45 46 47 48 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 44 def ref strong_memoize(:ref) do Gitlab::Git.ref_name(origin_ref) end end |
#sha ⇒ Object
50 51 52 53 54 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 50 def sha strong_memoize(:sha) do project.commit(origin_sha || origin_ref).try(:id) end end |
#tag_exists? ⇒ Boolean
31 32 33 34 35 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 31 def tag_exists? strong_memoize(:is_tag) do tag_ref? && project.repository.tag_exists?(ref) end end |