Class: Codebot::Formatters::Gitlab::PipelineHook
- Inherits:
-
Codebot::Formatter
- Object
- Codebot::Formatter
- Codebot::Formatters::Gitlab::PipelineHook
- Defined in:
- lib/codebot/formatters/gitlab_pipeline_hook.rb
Overview
Triggered on status change of pipeline
Instance Attribute Summary
Attributes inherited from Codebot::Formatter
Instance Method Summary collapse
-
#format ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#format_job_status ⇒ Object
rubocop:disable Metrics/MethodLength.
- #pipeline_id ⇒ Object
- #pipeline_status ⇒ Object
Methods inherited from Codebot::Formatter
#abbreviate, #action, #ary_to_sentence, #closed?, #extract, #format_branch, #format_dangerous, #format_event, #format_hash, #format_number, #format_repository, #format_url, #format_user, #gitlab_action, #gitlab_closed?, #gitlab_opened?, #gitlab_repository_url, #gitlab_url, #initialize, #opened?, #prettify, #repository_name, #repository_url, #sanitize, #sender_name, #shorten_url, #url
Constructor Details
This class inherits a constructor from Codebot::Formatter
Instance Method Details
#format ⇒ Object
rubocop:disable Metrics/MethodLength
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/codebot/formatters/gitlab_pipeline_hook.rb', line 31 def format # rubocop:disable Metrics/MethodLength repo_url = extract(:project, :web_url) repo_name = extract(:project, :path_with_namespace) pipeline_url = shorten_url "#{repo_url}/pipelines/#{pipeline_id}" reply = '[%<repository>s] pipeline %<status>s (%<url>s)' % { repository: format_repository(repo_name), status: format_job_status, url: pipeline_url } if pipeline_status == 'created' [reply + ':'] + [format_commit(extract(:commit))] else [reply] end end |
#format_job_status ⇒ Object
rubocop:disable Metrics/MethodLength
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/codebot/formatters/gitlab_pipeline_hook.rb', line 12 def format_job_status # rubocop:disable Metrics/MethodLength case pipeline_status when 'created' 'was created from commit' when 'success' 'succeeded' when 'skipped' 'was skipped' when /^fail/, /^err/ "failed: #{extract(:object_attributes, :detailed_status)}" else "did something: #{pipeline_status}" end end |
#pipeline_id ⇒ Object
27 28 29 |
# File 'lib/codebot/formatters/gitlab_pipeline_hook.rb', line 27 def pipeline_id extract(:object_attributes, :id) end |
#pipeline_status ⇒ Object
8 9 10 |
# File 'lib/codebot/formatters/gitlab_pipeline_hook.rb', line 8 def pipeline_status extract(:object_attributes, :status) end |