Class: CiService

Inherits:
Service
  • Object
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

Instance Method Summary collapse

Methods inherited from Service

#activated?, #async_execute, available_services_names, boolean_accessor, #can_test?, #category, create_from_template, #description, #execute, #fields, #help, #initialize_properties, #issue_tracker?, prop_accessor, #reset_updated_properties, #template?, #test, #title, #to_param, #updated_properties

Instance Method Details

#build_page(sha, ref) ⇒ Object

Return complete url to merge_request page

Ex.

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

52
53
54
# File 'app/models/project_services/ci_service.rb', line 52

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

#commit_page(sha, ref) ⇒ Object


43
44
45
# File 'app/models/project_services/ci_service.rb', line 43

def commit_page(sha, ref)
  build_page(sha, ref)
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'

86
87
88
# File 'app/models/project_services/ci_service.rb', line 86

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

#merge_request_page(iid, sha, ref) ⇒ Object


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

def merge_request_page(iid, sha, ref)
  commit_page(sha, ref)
end

#merge_request_status(iid, sha, ref) ⇒ Object

Return string with build status or :error symbol

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

Ex.

@service.merge_request_status(9, '13be4ac', 'dev')
# => 'success'

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

69
70
71
# File 'app/models/project_services/ci_service.rb', line 69

def merge_request_status(iid, sha, ref)
  commit_status(sha, ref)
end

#supported_eventsObject


35
36
37
# File 'app/models/project_services/ci_service.rb', line 35

def supported_events
  %w(push)
end

#valid_token?(token) ⇒ Boolean

Returns:

  • (Boolean)

31
32
33
# File 'app/models/project_services/ci_service.rb', line 31

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