Class: CiService

Inherits:
Service show all
Defined in:
app/models/project_services/ci_service.rb

Overview

Base class for CI services List methods you need to implement to get your CI service working with GitLab Merge Requests

Constant Summary

Constants inherited from Service

Service::DEV_SERVICE_NAMES, Service::SERVICE_NAMES

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service

#activated?, #api_field_names, #async_execute, available_services_names, available_services_types, boolean_accessor, build_from_integration, #can_test?, #category, #configurable_event_actions, #configurable_events, default_integration, #description, dev_services_names, #editable?, #event_channel_names, event_description, #event_field, event_names, #event_names, #execute, #fields, find_or_create_templates, find_or_initialize_all, find_or_initialize_integration, #global_fields, #help, #initialize_properties, instance_exists_for?, #issue_tracker?, #json_fields, #operating?, prop_accessor, #reset_updated_properties, services_names, services_types, #show_active_box?, supported_event_actions, #supported_events, #supports_data_fields?, #test, #title, #to_data_fields_hash, #to_param, to_param, #to_service_hash, #updated_properties

Methods included from ProjectServicesLoggable

#build_message, #log_error, #log_info, #logger

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.supported_eventsObject


13
14
15
# File 'app/models/project_services/ci_service.rb', line 13

def self.supported_events
  %w(push)
end

Instance Method Details

#build_page(sha, ref) ⇒ Object

Return complete url to build page

Ex.

http://jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c

22
23
24
# File 'app/models/project_services/ci_service.rb', line 22

def build_page(sha, ref)
  # implement inside child
end

#commit_status(sha, ref) ⇒ Object

Return string with build status or :error symbol

Allowed states: 'success', 'failed', 'running', 'pending', 'skipped'

Ex.

@service.commit_status('13be4ac', 'master')
# => 'success'

@service.commit_status('2abe4ac', 'dev')
# => 'running'

39
40
41
# File 'app/models/project_services/ci_service.rb', line 39

def commit_status(sha, ref)
  # implement inside child
end

#valid_token?(token) ⇒ Boolean

Returns:

  • (Boolean)

9
10
11
# File 'app/models/project_services/ci_service.rb', line 9

def valid_token?(token)
  self.respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.secure_compare(token, self.token)
end