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.
-
#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.
-
#gitaly_context ⇒ Object
Returns the value of attribute gitaly_context.
-
#ignore_skip_ci ⇒ Object
Returns the value of attribute ignore_skip_ci.
-
#inputs ⇒ Object
Returns the value of attribute inputs.
-
#linting ⇒ Object
Returns the value of attribute linting.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#merge_request ⇒ Object
Returns the value of attribute merge_request.
-
#mirror_update ⇒ Object
Returns the value of attribute mirror_update.
-
#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_creation_forced_to_continue ⇒ Object
Returns the value of attribute pipeline_creation_forced_to_continue.
-
#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.
-
#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
- #current_pipeline_size ⇒ Object
- #dry_run? ⇒ Boolean
- #increment_pipeline_failure_reason_counter(reason) ⇒ Object
- #jobs_count_in_alive_pipelines ⇒ Object
- #linting? ⇒ Boolean
- #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
- #readonly? ⇒ Boolean
- #ref ⇒ Object
- #sha ⇒ Object
- #tag_exists? ⇒ Boolean
- #workload_ref_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 |
#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 |
#gitaly_context ⇒ Object
Returns the value of attribute gitaly_context
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def gitaly_context @gitaly_context 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 |
#inputs ⇒ Object
Returns the value of attribute inputs
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def inputs @inputs end |
#linting ⇒ Object
Returns the value of attribute linting
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def linting @linting 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 |
#mirror_update ⇒ Object
Returns the value of attribute mirror_update
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def mirror_update @mirror_update 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_creation_forced_to_continue ⇒ Object
Returns the value of attribute pipeline_creation_forced_to_continue
7 8 9 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 7 def pipeline_creation_forced_to_continue @pipeline_creation_forced_to_continue 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 |
#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
79 80 81 82 83 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 79 def ambiguous_ref? strong_memoize(:ambiguous_ref) do project.repository.ambiguous_ref?(origin_ref) end end |
#branch_exists? ⇒ Boolean
33 34 35 36 37 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 33 def branch_exists? strong_memoize(:is_branch) do branch_ref? && project.repository.branch_exists?(ref) end end |
#creates_child_pipeline? ⇒ Boolean
93 94 95 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 93 def creates_child_pipeline? bridge&.triggers_child_pipeline? end |
#current_pipeline_size ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 105 def current_pipeline_size # The `pipeline_seed` attribute is assigned after the Seed step. # And, the seed is populated when calling the `pipeline_seed.stages` method in Populate. # So, there is no guarantee that `pipeline_seed` will return a meaningful result. # If it does not, it's not important, we can just return 0. # This is also the reason why we don't "strong memoize" this method. pipeline_seed&.size || 0 end |
#dry_run? ⇒ Boolean
25 26 27 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 25 def dry_run? dry_run end |
#increment_pipeline_failure_reason_counter(reason) ⇒ Object
148 149 150 151 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 148 def increment_pipeline_failure_reason_counter(reason) metrics.pipeline_failure_reason_counter .increment(reason: (reason || :unknown_failure).to_s) end |
#jobs_count_in_alive_pipelines ⇒ Object
114 115 116 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 114 def jobs_count_in_alive_pipelines project.all_pipelines.jobs_count_in_alive_pipelines end |
#linting? ⇒ Boolean
29 30 31 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 29 def linting? linting end |
#merge_request_ref_exists? ⇒ Boolean
45 46 47 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 45 def merge_request_ref_exists? check_merge_request_ref end |
#metrics ⇒ Object
97 98 99 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 97 def metrics @metrics ||= ::Gitlab::Ci::Pipeline::Metrics end |
#observe_creation_duration(duration) ⇒ Object
129 130 131 132 133 134 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 129 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
143 144 145 146 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 143 def observe_jobs_count_in_alive_pipelines metrics.active_jobs_histogram .observe({ plan: project.actual_plan_name }, jobs_count_in_alive_pipelines + current_pipeline_size) end |
#observe_pipeline_size(pipeline) ⇒ Object
136 137 138 139 140 141 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 136 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
119 120 121 122 123 124 125 126 127 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 119 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
65 66 67 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 65 def origin_sha checkout_sha || after_sha end |
#parent_pipeline ⇒ Object
85 86 87 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 85 def parent_pipeline bridge&.parent_pipeline end |
#parent_pipeline_partition_id ⇒ Object
89 90 91 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 89 def parent_pipeline_partition_id parent_pipeline.partition_id if creates_child_pipeline? end |
#protected_ref? ⇒ Boolean
73 74 75 76 77 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 73 def protected_ref? strong_memoize(:protected_ref) do project.protected_for?(origin_ref) end end |
#readonly? ⇒ Boolean
21 22 23 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 21 def readonly? dry_run? || linting? end |
#ref ⇒ Object
53 54 55 56 57 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 53 def ref strong_memoize(:ref) do Gitlab::Git.ref_name(origin_ref) end end |
#sha ⇒ Object
59 60 61 62 63 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 59 def sha strong_memoize(:sha) do project.commit(origin_sha || origin_ref).try(:id) end end |
#tag_exists? ⇒ Boolean
39 40 41 42 43 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 39 def tag_exists? strong_memoize(:is_tag) do tag_ref? && project.repository.tag_exists?(ref) end end |
#workload_ref_exists? ⇒ Boolean
49 50 51 |
# File 'lib/gitlab/ci/pipeline/chain/command.rb', line 49 def workload_ref_exists? ::Ci::Workloads::Workload.workload_ref?(origin_ref) && project.repository.ref_exists?(origin_ref) end |