From 311f8855f45c986c97b722e8fac0c4466a4d632f Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 10 Jun 2018 21:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8output=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 20 ++++---- .../_pull_requests_list.html.erb | 2 +- app/views/pull_requests/pr_console.html.erb | 48 ------------------- ...055_add_jenkins_output_to_pull_requests.rb | 5 ++ 4 files changed, 17 insertions(+), 58 deletions(-) create mode 100644 db/migrate/20180610133055_add_jenkins_output_to_pull_requests.rb diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 6915227a5..280e482b0 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -213,21 +213,23 @@ class PullRequestsController < ApplicationController # 获取jenkins输出结果 def pr_console job_name = params[:job_name] + pr = PullRequest.where(:pull_request_id => params[:pr_id]).first 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 = 'html')["output"] - @output2 = @output.gsub("\n", "\r\n") - @output2 = @output.gsub("\n", "\r") - @output3 = @output.gsub("\r\n", "\n") - @output4 = @output.gsub("\r\n", "\r") - @output5 = @output.gsub("\r", "\n") - @output6 = @output.gsub("\r", "\r\n") - @output7 = @output.gsub("\t", "\t\n") - @output8 = @output.gsub("\t", "\n") - @output9 = @output.gsub("\t", "\r") + pr.update_column(:jenkins_output, @output) + # @output2 = @output.gsub("\n", "\r\n") + # @output2 = @output.gsub("\n", "\r") + # @output3 = @output.gsub("\r\n", "\n") + # @output4 = @output.gsub("\r\n", "\r") + # @output5 = @output.gsub("\r", "\n") + # @output6 = @output.gsub("\r", "\r\n") + # @output7 = @output.gsub("\t", "\t\n") + # @output8 = @output.gsub("\t", "\n") + # @output9 = @output.gsub("\t", "\r") logger.info("jenkins ###########################{@output}") logger.info("jenkins 1111111111111111111111111##{@output2}") end diff --git a/app/views/pull_requests/_pull_requests_list.html.erb b/app/views/pull_requests/_pull_requests_list.html.erb index ad150ddaf..0d6b9948a 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_pull_requests_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, :pr_id => request.id), :class => "linkBlue2 ml10 mr10", :target => "_blank" %>

质量检测结果

<% end %> diff --git a/app/views/pull_requests/pr_console.html.erb b/app/views/pull_requests/pr_console.html.erb index c2c8c7e89..6c6551ef4 100644 --- a/app/views/pull_requests/pr_console.html.erb +++ b/app/views/pull_requests/pr_console.html.erb @@ -3,51 +3,3 @@ <%= @output.html_safe %> -22222222222222 -
-
- <%= @output2.html_safe %> -
-
-33333333333333 -
-
- <%= @output3.html_safe %> -
-
-4444444444445 -
-
- <%= @output4.html_safe %> -
-
-
-
- <%= @output5.html_safe %> -
-
-
-
- <%= @output6.html_safe %> -
-
-
-
- <%= @output6.html_safe %> -
-
-
-
- <%= @output4.html_safe %> -
-
-
-
- <%= @output8.html_safe %> -
-
-
-
- <%= @output9.html_safe %> -
-
\ No newline at end of file diff --git a/db/migrate/20180610133055_add_jenkins_output_to_pull_requests.rb b/db/migrate/20180610133055_add_jenkins_output_to_pull_requests.rb new file mode 100644 index 000000000..f31fc1104 --- /dev/null +++ b/db/migrate/20180610133055_add_jenkins_output_to_pull_requests.rb @@ -0,0 +1,5 @@ +class AddJenkinsOutputToPullRequests < ActiveRecord::Migration + def change + add_column :pull_requests, :jenkins_output, :longtext + end +end