mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-16 16:16:43 +10:00
Add parent CiService class for easy add of new services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# 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
|
||||
|
||||
# Return complete url to build page
|
||||
#
|
||||
# Ex.
|
||||
# http://jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c
|
||||
#
|
||||
def build_page(sha)
|
||||
# implement inside child
|
||||
end
|
||||
|
||||
# Return string with build status or :error symbol
|
||||
#
|
||||
# Allowed states: 'success', 'failed', 'running', 'pending'
|
||||
#
|
||||
#
|
||||
# Ex.
|
||||
# @service.commit_status('13be4ac')
|
||||
# # => 'success'
|
||||
#
|
||||
# @service.commit_status('2abe4ac')
|
||||
# # => 'running'
|
||||
#
|
||||
#
|
||||
def commit_status(sha)
|
||||
# implement inside child
|
||||
end
|
||||
end
|
||||
@@ -17,7 +17,7 @@
|
||||
# api_key :string(255)
|
||||
#
|
||||
|
||||
class GitlabCiService < Service
|
||||
class GitlabCiService < CiService
|
||||
attr_accessible :project_url
|
||||
|
||||
validates :project_url, presence: true, if: :activated?
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# api_key :string(255)
|
||||
#
|
||||
|
||||
class JenkinsService < Service
|
||||
class JenkinsService < CiService
|
||||
attr_accessible :project_url
|
||||
|
||||
validates :project_url, presence: true, if: :activated?
|
||||
@@ -55,7 +55,7 @@ class JenkinsService < Service
|
||||
end
|
||||
|
||||
def commit_status sha
|
||||
response = HTTParty.get(commit_status_path(sha), verify: false)
|
||||
response = HTTParty.get(build_page(sha), verify: false)
|
||||
|
||||
if response.code == 200
|
||||
if response.include?('alt="Success"')
|
||||
@@ -71,8 +71,4 @@ class JenkinsService < Service
|
||||
:error
|
||||
end
|
||||
end
|
||||
|
||||
def commit_status_path sha
|
||||
project_url + "/job/test1/scm/bySHA1/#{sha}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,6 +33,10 @@ class Service < ActiveRecord::Base
|
||||
active
|
||||
end
|
||||
|
||||
def category
|
||||
:common
|
||||
end
|
||||
|
||||
def title
|
||||
# implement inside child
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user