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 ...@@ -161,7 +161,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def ci_status 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} response = {status: status}
render json: response render json: response
......
...@@ -32,7 +32,7 @@ module MergeRequestsHelper ...@@ -32,7 +32,7 @@ module MergeRequestsHelper
end end
def ci_build_details_path merge_request 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 end
def merge_path_description(merge_request, separator) def merge_path_description(merge_request, separator)
......
...@@ -322,17 +322,29 @@ class Project < ActiveRecord::Base ...@@ -322,17 +322,29 @@ class Project < ActiveRecord::Base
end end
def available_services_names def available_services_names
<<<<<<< HEAD %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack jira jenkins)
%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
end end
def gitlab_ci? def gitlab_ci?
gitlab_ci_service && gitlab_ci_service.active gitlab_ci_service && gitlab_ci_service.active
end 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? def jira_tracker?
self.issues_tracker == "jira" self.issues_tracker == "jira"
end end
......
...@@ -49,4 +49,30 @@ class JenkinsService < Service ...@@ -49,4 +49,30 @@ class JenkinsService < Service
{ type: 'text', name: 'project_url', placeholder: 'Jenkins server URL like http://jenkins.example.com/' } { type: 'text', name: 'project_url', placeholder: 'Jenkins server URL like http://jenkins.example.com/' }
] ]
end 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 end
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}", url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}",
check_enable: #{@merge_request.unchecked? ? "true" : "false"}, check_enable: #{@merge_request.unchecked? ? "true" : "false"},
url_to_ci_check: "#{ci_status_project_merge_request_path(@project, @merge_request)}", 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}", current_status: "#{@merge_request.merge_status_name}",
action: "#{controller.action_name}" action: "#{controller.action_name}"
}); });
.panel.mr-state-widget.panel-default .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 .panel-heading
= render "projects/merge_requests/show/mr_ci" = render "projects/merge_requests/show/mr_ci"
.panel-body .panel-body
......
...@@ -189,9 +189,9 @@ ActiveRecord::Schema.define(version: 20140513095908) do ...@@ -189,9 +189,9 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.datetime "updated_at" t.datetime "updated_at"
t.string "type" t.string "type"
t.string "description", default: "", null: false t.string "description", default: "", null: false
t.string "avatar"
t.string "ldap_cn" t.string "ldap_cn"
t.integer "ldap_access" t.integer "ldap_access"
t.string "avatar"
end end
add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree
...@@ -238,20 +238,20 @@ ActiveRecord::Schema.define(version: 20140513095908) do ...@@ -238,20 +238,20 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "creator_id" t.integer "creator_id"
t.boolean "issues_enabled", default: true, null: false t.boolean "issues_enabled", default: true, null: false
t.boolean "wall_enabled", default: true, null: false t.boolean "wall_enabled", default: true, null: false
t.boolean "merge_requests_enabled", default: true, null: false t.boolean "merge_requests_enabled", default: true, null: false
t.boolean "wiki_enabled", default: true, null: false t.boolean "wiki_enabled", default: true, null: false
t.integer "namespace_id" 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.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.datetime "last_activity_at"
t.string "import_url" t.string "import_url"
t.integer "visibility_level", default: 0, null: false t.integer "visibility_level", default: 0, null: false
t.boolean "archived", default: false, null: false t.boolean "archived", default: false, null: false
t.string "import_status" t.string "import_status"
t.float "repository_size", default: 0.0 t.float "repository_size", default: 0.0
t.text "merge_requests_template" t.text "merge_requests_template"
end end
...@@ -357,6 +357,7 @@ ActiveRecord::Schema.define(version: 20140513095908) do ...@@ -357,6 +357,7 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.integer "notification_level", default: 1, null: false t.integer "notification_level", default: 1, null: false
t.datetime "password_expires_at" t.datetime "password_expires_at"
t.integer "created_by_id" t.integer "created_by_id"
t.datetime "last_credential_check_at"
t.string "avatar" t.string "avatar"
t.string "confirmation_token" t.string "confirmation_token"
t.datetime "confirmed_at" t.datetime "confirmed_at"
...@@ -364,7 +365,6 @@ ActiveRecord::Schema.define(version: 20140513095908) do ...@@ -364,7 +365,6 @@ ActiveRecord::Schema.define(version: 20140513095908) do
t.string "unconfirmed_email" t.string "unconfirmed_email"
t.boolean "hide_no_ssh_key", default: false t.boolean "hide_no_ssh_key", default: false
t.string "website_url", default: "", null: false t.string "website_url", default: "", null: false
t.datetime "last_credential_check_at"
end end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree 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