2014-08-25 05:25:02 -04:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: services
|
|
|
|
#
|
2015-03-04 17:14:00 -05:00
|
|
|
# id :integer not null, primary key
|
|
|
|
# type :string(255)
|
|
|
|
# title :string(255)
|
|
|
|
# project_id :integer
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
# active :boolean default(FALSE), not null
|
|
|
|
# properties :text
|
|
|
|
# template :boolean default(FALSE)
|
|
|
|
# push_events :boolean default(TRUE)
|
|
|
|
# issues_events :boolean default(TRUE)
|
|
|
|
# merge_requests_events :boolean default(TRUE)
|
|
|
|
# tag_push_events :boolean default(TRUE)
|
2015-05-03 12:05:38 -04:00
|
|
|
# note_events :boolean default(TRUE), not null
|
2014-08-25 05:25:02 -04:00
|
|
|
#
|
|
|
|
|
2014-05-28 04:35:43 -04:00
|
|
|
# Base class for CI services
|
|
|
|
# List methods you need to implement to get your CI service
|
|
|
|
# working with GitLab Merge Requests
|
|
|
|
class CiService < Service
|
|
|
|
def category
|
|
|
|
:ci
|
|
|
|
end
|
2015-08-26 19:58:49 -04:00
|
|
|
|
|
|
|
def valid_token?(token)
|
|
|
|
self.respond_to?(:token) && self.token.present? && self.token == token
|
|
|
|
end
|
|
|
|
|
2015-02-28 11:33:18 -05:00
|
|
|
def supported_events
|
|
|
|
%w(push)
|
|
|
|
end
|
|
|
|
|
2015-08-26 19:58:49 -04:00
|
|
|
def merge_request_page(iid, sha, ref)
|
|
|
|
commit_page(sha, ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
def commit_page(sha, ref)
|
|
|
|
build_page(sha, ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return complete url to merge_request page
|
2014-05-28 04:35:43 -04:00
|
|
|
#
|
|
|
|
# Ex.
|
|
|
|
# http://jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c
|
|
|
|
#
|
2015-03-05 09:58:04 -05:00
|
|
|
def build_page(sha, ref)
|
2014-05-28 04:35:43 -04:00
|
|
|
# implement inside child
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return string with build status or :error symbol
|
|
|
|
#
|
2015-07-30 07:58:47 -04:00
|
|
|
# Allowed states: 'success', 'failed', 'running', 'pending', 'skipped'
|
2014-05-28 04:35:43 -04:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# Ex.
|
2015-08-26 19:58:49 -04:00
|
|
|
# @service.merge_request_status(9, '13be4ac', 'dev')
|
|
|
|
# # => 'success'
|
|
|
|
#
|
|
|
|
# @service.merge_request_status(10, '2abe4ac', 'dev)
|
|
|
|
# # => 'running'
|
|
|
|
#
|
|
|
|
#
|
|
|
|
def merge_request_status(iid, sha, ref)
|
|
|
|
commit_status(sha, ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return string with build status or :error symbol
|
|
|
|
#
|
|
|
|
# Allowed states: 'success', 'failed', 'running', 'pending', 'skipped'
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Ex.
|
|
|
|
# @service.commit_status('13be4ac', 'master')
|
2014-05-28 04:35:43 -04:00
|
|
|
# # => 'success'
|
|
|
|
#
|
2015-08-26 19:58:49 -04:00
|
|
|
# @service.commit_status('2abe4ac', 'dev')
|
2014-05-28 04:35:43 -04:00
|
|
|
# # => 'running'
|
|
|
|
#
|
|
|
|
#
|
2015-03-05 09:58:04 -05:00
|
|
|
def commit_status(sha, ref)
|
2014-05-28 04:35:43 -04:00
|
|
|
# implement inside child
|
|
|
|
end
|
|
|
|
end
|