consloe pring

This commit is contained in:
txz 2016-07-01 17:50:08 +08:00
parent a5f3b304d7
commit 25e77497e7
6 changed files with 35 additions and 8 deletions

View File

@ -2,7 +2,7 @@ class QualityAnalysisController < ApplicationController
before_filter :find_project_by_project_id#, :except => [:getattachtype]
before_filter :find_quality_analysis, :only => [:edit, :update_jenkins_job]
before_filter :authorize
before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job]
before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job, :index]
layout "base_projects"
include ApplicationHelper
include QualityAnalysisHelper
@ -78,7 +78,7 @@ class QualityAnalysisController < ApplicationController
d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201'
logger.error("delete result ==> #{code}")
if qa.blank? && code == '201'
if qa.blank? && @current_build_status == "success"
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
:sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}")
else
@ -89,7 +89,7 @@ class QualityAnalysisController < ApplicationController
puts e
end
respond_to do |format|
format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)}
format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
# format.js{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)}
end
end
@ -167,6 +167,7 @@ class QualityAnalysisController < ApplicationController
begin
@resource_id = params[:resource_id]
@sonar_address = Redmine::Configuration['sonar_address']
@jenkins_address = Redmine::Configuration['jenkins_address']
if params[:resource_id].nil?
@name_flag = true
projects_date = open(@sonar_address + "/api/projects/index").read
@ -174,6 +175,10 @@ class QualityAnalysisController < ApplicationController
@quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)}
else
if params[:current_build_status] == "failure"
job_name = params[:job_name]
@console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')
end
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read
@complexity =JSON.parse(complexity_date).first
issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read

View File

@ -0,0 +1,8 @@
<%= javascript_include_tag 'highcharts','highcharts-more' %>
<div class="project_r_h">
<h2 class="project_h2" style="width:180px;">质量分析</h2>
</div>
<p>
<%= h @console_build.to_json.html_safe %>
</p>

View File

@ -0,0 +1,9 @@
<% if @current_build_status == "success" %>
<%= render :partial => "show", :locals => {:branch => params[:branch]} %>
<% else %>
<% if @build_console_result %>
运行结果超时
<% else %>
<%= render :partial => "console_output" %>
<% end %>
<% end %>

View File

@ -1,10 +1,14 @@
<% if @name_flag %>
<%= render :partial => "result_list" %>
<% else %>
<% if @build_console_result %>
运行结果超时
<% else %>
<% if params[:current_build_status].nil? || params[:current_build_status] == "success" %>
<%= render :partial => "show", :locals => {:branch => params[:branch]} %>
<% else %>
<% if params[:build_console_result] %>
运行结果超时
<% else %>
<%= render :partial => "console_output" %>
<% end %>
<% end %>
<% end %>

View File

@ -5,9 +5,9 @@
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
<%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %>
<%# if User.current.member_of?(@project) %>
<%# if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) %>
<% if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) && @project.is_public? %>
<%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %>
<%# end %>
<% end %>
<%# end %>
<%# else %>
<%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %>

View File

@ -792,6 +792,7 @@ RedmineApp::Application.routes.draw do
member do
match 'update_jenkins_job'
match 'edit'
match 'create'
end
end
# resources :files, :only => [:index, :new, :create] do