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

88 lines
2.1 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
# == Schema Information
#
# Table name: services
#
# 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-09-11 14:41:01 +05:30
# note_events :boolean default(TRUE), not null
2015-04-26 12:48:37 +05:30
#
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
def category
:ci
end
2015-09-25 12:07:36 +05:30
def valid_token?(token)
self.respond_to?(:token) && self.token.present? && self.token == token
end
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