1 # == Schema Information
5 # id :integer not null, primary key
9 # project_id :integer not null
10 # created_at :datetime not null
11 # updated_at :datetime not null
12 # active :boolean default(FALSE), not null
13 # project_url :string(255)
16 class GitlabCiService < Service
17 attr_accessible :project_url
19 validates :project_url, presence: true, if: :activated?
20 validates :token, presence: true, if: :activated?
22 delegate :execute, to: :service_hook, prefix: nil
24 after_save :compose_service_hook, if: :activated?
26 def compose_service_hook
27 hook = service_hook || build_service_hook
28 hook.url = [project_url, "/build", "?token=#{token}"].join("")
32 def commit_status_path sha
33 project_url + "/builds/#{sha}/status.json?token=#{token}"
37 response = HTTParty.get(commit_status_path(sha))
39 if response.code == 200 and response["status"]
47 project_url + "/builds/#{sha}"