debian-mirror-gitlab/app/models/project_services/ci_service.rb

66 lines
1.4 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
# Base class for CI services
# List methods you need to implement to get your CI service
# working with GitLab Merge Requests
class CiService < Service
2016-01-29 22:53:50 +05:30
default_value_for :category, 'ci'
2015-09-25 12:07:36 +05:30
def valid_token?(token)
2016-06-02 11:05:42 +05:30
self.respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.token)
2015-09-25 12:07:36 +05:30
end
2016-01-29 22:53:50 +05:30
2015-04-26 12:48:37 +05:30
def supported_events
%w(push)
end
2015-09-25 12:07:36 +05:30
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-09-02 18:07:02 +05:30
#
# Ex.
# http://jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c
#
2015-04-26 12:48:37 +05:30
def build_page(sha, ref)
2014-09-02 18:07:02 +05:30
# implement inside child
end
# Return string with build status or :error symbol
#
2015-09-11 14:41:01 +05:30
# Allowed states: 'success', 'failed', 'running', 'pending', 'skipped'
2014-09-02 18:07:02 +05:30
#
#
# Ex.
2015-09-25 12:07:36 +05:30
# @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-09-02 18:07:02 +05:30
# # => 'success'
#
2015-09-25 12:07:36 +05:30
# @service.commit_status('2abe4ac', 'dev')
2014-09-02 18:07:02 +05:30
# # => 'running'
#
#
2015-04-26 12:48:37 +05:30
def commit_status(sha, ref)
2014-09-02 18:07:02 +05:30
# implement inside child
end
end