Commit e6d2c02e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Dirty implementastion of MR build status for Jenkins

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 84b35507
......@@ -161,7 +161,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def ci_status
status = @merge_request.source_project.gitlab_ci_service.commit_status(merge_request.last_commit.sha)
status = @merge_request.source_project.ci_service.commit_status(merge_request.last_commit.sha)
response = {status: status}
render json: response
......
......@@ -32,7 +32,7 @@ module MergeRequestsHelper
end
def ci_build_details_path merge_request
merge_request.source_project.gitlab_ci_service.build_page(merge_request.last_commit.sha)
merge_request.source_project.ci_service.build_page(merge_request.last_commit.sha)
end
def merge_path_description(merge_request, separator)
......
......@@ -322,17 +322,29 @@ class Project < ActiveRecord::Base
end
def available_services_names
<<<<<<< HEAD
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack jira)
=======
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack jenkins)
>>>>>>> Add Jenkins CI service
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack jira jenkins)
end
def gitlab_ci?
gitlab_ci_service && gitlab_ci_service.active
end
def jenkins_enabled?
jenkins_service && jenkins_service.active
end
def enabled_ci?
gitlab_ci? || jenkins_enabled?
end
def ci_service
if gitlab_ci?
gitlab_ci_service
elsif jenkins_enabled?
jenkins_service
end
end
def jira_tracker?
self.issues_tracker == "jira"
end
......
......@@ -49,4 +49,30 @@ class JenkinsService < Service
{ type: 'text', name: 'project_url', placeholder: 'Jenkins server URL like http://jenkins.example.com/' }
]
end
def build_page sha
project_url + "/job/test1/scm/bySHA1/#{sha}"
end
def commit_status sha
response = HTTParty.get(commit_status_path(sha), verify: false)
if response.code == 200
if response.include?('alt="Success"')
'success'
elsif response.include?('alt="Failed"')
'failed'
elsif response.include?('alt="In progress"')
'running'
else
'pending'
end
else
:error
end
end
def commit_status_path sha
project_url + "/job/test1/scm/bySHA1/#{sha}"
end
end
......@@ -37,7 +37,7 @@
url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}",
check_enable: #{@merge_request.unchecked? ? "true" : "false"},
url_to_ci_check: "#{ci_status_project_merge_request_path(@project, @merge_request)}",
ci_enable: #{@project.gitlab_ci? ? "true" : "false"},
ci_enable: #{@project.ci_service ? "true" : "false"},
current_status: "#{@merge_request.merge_status_name}",
action: "#{controller.action_name}"
});
.panel.mr-state-widget.panel-default
- if @merge_request.source_project.gitlab_ci? && @commits.any?
- if @merge_request.source_project.ci_service && @commits.any?
.panel-heading
= render "projects/merge_requests/show/mr_ci"
.panel-body
......
......@@ -189,9 +189,9 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.datetime "updated_at"
t.string "type"
t.string "description", default: "", null: false
t.string "avatar"
t.string "ldap_cn"
t.integer "ldap_access"
t.string "avatar"
end
add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree
......@@ -238,20 +238,20 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "creator_id"
t.boolean "issues_enabled", default: true, null: false
t.boolean "wall_enabled", default: true, null: false
t.boolean "merge_requests_enabled", default: true, null: false
t.boolean "wiki_enabled", default: true, null: false
t.boolean "issues_enabled", default: true, null: false
t.boolean "wall_enabled", default: true, null: false
t.boolean "merge_requests_enabled", default: true, null: false
t.boolean "wiki_enabled", default: true, null: false
t.integer "namespace_id"
t.string "issues_tracker", default: "gitlab", null: false
t.string "issues_tracker", default: "gitlab", null: false
t.string "issues_tracker_id"
t.boolean "snippets_enabled", default: true, null: false
t.boolean "snippets_enabled", default: true, null: false
t.datetime "last_activity_at"
t.string "import_url"
t.integer "visibility_level", default: 0, null: false
t.boolean "archived", default: false, null: false
t.integer "visibility_level", default: 0, null: false
t.boolean "archived", default: false, null: false
t.string "import_status"
t.float "repository_size", default: 0.0
t.float "repository_size", default: 0.0
t.text "merge_requests_template"
end
......@@ -357,6 +357,7 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.integer "notification_level", default: 1, null: false
t.datetime "password_expires_at"
t.integer "created_by_id"
t.datetime "last_credential_check_at"
t.string "avatar"
t.string "confirmation_token"
t.datetime "confirmed_at"
......@@ -364,7 +365,6 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.string "unconfirmed_email"
t.boolean "hide_no_ssh_key", default: false
t.string "website_url", default: "", null: false
t.datetime "last_credential_check_at"
end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment