2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
# Base class for CI services
|
|
|
|
# List methods you need to implement to get your CI service
|
2021-04-29 21:17:54 +05:30
|
|
|
# working with GitLab merge requests
|
2014-09-02 18:07:02 +05:30
|
|
|
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)
|
2019-09-30 21:07:59 +05:30
|
|
|
self.respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.secure_compare(token, self.token)
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
2016-01-29 22:53:50 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def self.supported_events
|
2015-04-26 12:48:37 +05:30
|
|
|
%w(push)
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
# Return complete url to build 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
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
# 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
|