pull request分析中添加jenkins执行过程

This commit is contained in:
huang 2018-06-10 20:41:21 +08:00
parent c080cf6c94
commit 33b8a1d101
3 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -18,7 +18,7 @@
<% qa = QualityAnalysis.where(:pull_request_id => request.id).first %>
<% if qa.present? %>
<p class="fr"><%= link_to "执行过程", pr_console_project_quality_analysis_path(:job_name => qa.sonar_name), :class => "linkBlue2 ml10 mr10", :target => "_blank" %></p>
<p class="fr"><%= link_to "执行过程", pr_console_project_pull_requests_path(:job_name => qa.sonar_name), :class => "linkBlue2 ml10 mr10", :target => "_blank" %></p>
<p class="fr"><a class="linkBlue2 ml10 mr10" href="http://sonar.trustie.net/dashboard/index/<%= qa.sonar_name %>" target="_blank">质量检测结果</a></p>
<% end %>
</div>

View File

@ -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'