From 33b8a1d101b972005a1e63128a03c16d762e92f1 Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 10 Jun 2018 20:41:21 +0800 Subject: [PATCH] =?UTF-8?q?pull=20request=E5=88=86=E6=9E=90=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0jenkins=E6=89=A7=E8=A1=8C=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 12 ++++++++++++ app/views/pull_requests/_pull_requests_list.html.erb | 2 +- config/routes.rb | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 9fbc89bcb..d4a317462 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -210,6 +210,18 @@ class PullRequestsController < ApplicationController status = (git_sourse_commit_id == git_target_commit_id ? false : true) end + # 获取jenkins输出结果 + def pr_console + job_name = params[:job_name] + jenkins_address = Redmine::Configuration['jenkins_address'] + jenkins_username = Redmine::Configuration['jenkins_username'] + jenkins_password = Redmine::Configuration['jenkins_password'] + # connect jenkins + client_jenkins = JenkinsApi::Client.new(:server_url => jenkins_address, :username => jenkins_username, :password => jenkins_password) + @output = client_jenkins.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"] + end + + # @project_menu_type 为了控制base顶部导航 # merge_when_succeeds def show diff --git a/app/views/pull_requests/_pull_requests_list.html.erb b/app/views/pull_requests/_pull_requests_list.html.erb index b64626a60..ad150ddaf 100644 --- a/app/views/pull_requests/_pull_requests_list.html.erb +++ b/app/views/pull_requests/_pull_requests_list.html.erb @@ -18,7 +18,7 @@ <% qa = QualityAnalysis.where(:pull_request_id => request.id).first %> <% if qa.present? %> -

<%= link_to "执行过程", pr_console_project_quality_analysis_path(:job_name => qa.sonar_name), :class => "linkBlue2 ml10 mr10", :target => "_blank" %>

+

<%= link_to "执行过程", pr_console_project_pull_requests_path(:job_name => qa.sonar_name), :class => "linkBlue2 ml10 mr10", :target => "_blank" %>

质量检测结果

<% end %> diff --git a/config/routes.rb b/config/routes.rb index b657a0496..b4f331efe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1015,6 +1015,7 @@ RedmineApp::Application.routes.draw do resources :pull_requests do collection do + get 'pr_console' end member do get 'accept_pull_request' @@ -1028,7 +1029,6 @@ RedmineApp::Application.routes.draw do resources :quality_analysis, :only => [:index, :create, :edit, :update, :delete] do collection do - get 'pr_console' end member do match 'update_jenkins_job'