2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
class CommitStatusPresenter < Gitlab :: View :: Presenter :: Delegated
CALLOUT_FAILURE_MESSAGES = {
2018-11-18 11:00:15 +05:30
unknown_failure : 'There is an unknown failure, please try again' ,
script_failure : nil ,
api_failure : 'There has been an API failure, please try again' ,
stuck_or_timeout_failure : 'There has been a timeout failure or the job got stuck. Check your timeout limits or try again' ,
runner_system_failure : 'There has been a runner system failure, please try again' ,
missing_dependency_failure : 'There has been a missing dependency failure' ,
2018-12-05 23:21:45 +05:30
runner_unsupported : 'Your runner is outdated, please upgrade your runner' ,
2018-12-13 13:39:08 +05:30
stale_schedule : 'Delayed job could not be executed by some reason, please try again' ,
job_execution_timeout : 'The script exceeded the maximum execution time set for the job' ,
2019-07-07 11:18:12 +05:30
archived_failure : 'The job is archived and cannot be run' ,
2019-12-26 22:10:19 +05:30
unmet_prerequisites : 'The job failed to complete prerequisite tasks' ,
scheduler_failure : 'The scheduler failed to assign job to the runner, please try again or contact system administrator' ,
2020-03-13 15:44:24 +05:30
data_integrity_failure : 'There has been a structural integrity problem detected, please contact system administrator' ,
forward_deployment_failure : 'The deployment job is older than the previously succeeded deployment job, and therefore cannot be run' ,
2021-06-08 01:23:25 +05:30
pipeline_loop_detected : 'This job could not be executed because it would create infinitely looping pipelines' ,
2022-08-13 15:12:31 +05:30
insufficient_upstream_permissions : 'This job could not be executed because of insufficient permissions to track the upstream project.' ,
upstream_bridge_project_not_found : 'This job could not be executed because upstream bridge project could not be found.' ,
2020-03-13 15:44:24 +05:30
invalid_bridge_trigger : 'This job could not be executed because downstream pipeline trigger definition is invalid' ,
downstream_bridge_project_not_found : 'This job could not be executed because downstream bridge project could not be found' ,
2022-08-13 15:12:31 +05:30
protected_environment_failure : 'The environment this job is deploying to is protected. Only users with permission may successfully run this job.' ,
2020-03-13 15:44:24 +05:30
insufficient_bridge_permissions : 'This job could not be executed because of insufficient permissions to create a downstream pipeline' ,
bridge_pipeline_is_child_pipeline : 'This job belongs to a child pipeline and cannot create further child pipelines' ,
2020-10-24 23:57:45 +05:30
downstream_pipeline_creation_failed : 'The downstream pipeline could not be created' ,
2020-11-24 15:15:51 +05:30
secrets_provider_not_found : 'The secrets provider can not be found' ,
2021-04-29 21:17:54 +05:30
reached_max_descendant_pipelines_depth : 'You reached the maximum depth of child pipelines' ,
2022-10-11 01:57:18 +05:30
reached_max_pipeline_hierarchy_size : 'The downstream pipeline tree is too large' ,
2021-04-29 21:17:54 +05:30
project_deleted : 'The job belongs to a deleted project' ,
2021-06-08 01:23:25 +05:30
user_blocked : 'The user who created this job is blocked' ,
2021-09-04 01:27:46 +05:30
ci_quota_exceeded : 'No more CI minutes available' ,
2021-09-30 23:02:18 +05:30
no_matching_runner : 'No matching runner available' ,
2021-11-11 11:23:49 +05:30
trace_size_exceeded : 'The job log size limit was reached' ,
2021-11-18 22:05:49 +05:30
builds_disabled : 'The CI/CD is disabled for this project' ,
2022-01-26 12:08:38 +05:30
environment_creation_failure : 'This job could not be executed because it would create an environment with an invalid parameter.' ,
2022-07-01 11:34:44 +05:30
deployment_rejected : 'This deployment job was rejected.' ,
2022-10-11 01:57:18 +05:30
ip_restriction_failure : " This job could not be executed because group IP address restrictions are enabled, and the runner's IP address is not in the allowed range. " ,
failed_outdated_deployment_job : 'The deployment job is older than the latest deployment, and therefore failed.'
2021-11-18 22:05:49 +05:30
} . freeze
TROUBLESHOOTING_DOC = {
2022-10-11 01:57:18 +05:30
environment_creation_failure : { path : 'ci/environments/index' , anchor : 'a-deployment-job-failed-with-this-job-could-not-be-executed-because-it-would-create-an-environment-with-an-invalid-parameter-error' } ,
2023-01-13 00:05:48 +05:30
failed_outdated_deployment_job : { path : 'ci/environments/deployment_safety' , anchor : 'prevent-outdated-deployment-jobs' }
2018-10-15 14:42:47 +05:30
} . freeze
2018-11-20 20:47:30 +05:30
private_constant :CALLOUT_FAILURE_MESSAGES
2022-06-21 17:19:12 +05:30
presents :: CommitStatus
2018-10-15 14:42:47 +05:30
2018-11-20 20:47:30 +05:30
def self . callout_failure_messages
CALLOUT_FAILURE_MESSAGES
end
2018-10-15 14:42:47 +05:30
def callout_failure_message
2021-11-18 22:05:49 +05:30
message = self . class . callout_failure_messages . fetch ( failure_reason . to_sym )
if doc = TROUBLESHOOTING_DOC [ failure_reason . to_sym ]
message += " #{ help_page_link ( doc [ :path ] , doc [ :anchor ] ) } "
end
message
end
private
def help_page_link ( path , anchor )
ActionController :: Base . helpers . link_to ( 'How do I fix it?' , help_page_path ( path , anchor : anchor ) )
2018-10-15 14:42:47 +05:30
end
end