sonar error puts
This commit is contained in:
parent
88f8752490
commit
92b6171c36
|
@ -61,7 +61,7 @@ class QualityAnalysisController < ApplicationController
|
|||
# 判断调用sonar分析是否成功
|
||||
# 等待启动时间处理, 最长时间为30分钟
|
||||
for i in 0..60 do
|
||||
sleep(60)
|
||||
sleep(30)
|
||||
@current_build_status = @client.job.get_current_build_status("#{job_name}")
|
||||
if (@current_build_status != "not_run" || @current_build_status != "running")
|
||||
break
|
||||
|
@ -74,23 +74,27 @@ class QualityAnalysisController < ApplicationController
|
|||
|
||||
@console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')
|
||||
logger.info("@current_build_status is ==> #{@current_build_status}")
|
||||
logger.info("@console_build is ==> #{@console_build}")
|
||||
|
||||
d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201'
|
||||
logger.error("delete result ==> #{code}")
|
||||
if @current_build_status == "success"
|
||||
SonarError.create()
|
||||
end
|
||||
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
|
||||
qa.update_attribute(:sonar_version, version)
|
||||
qa.update_attribute(:sonar_version, version) unless qa.blank?
|
||||
end
|
||||
end
|
||||
rescue => e
|
||||
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, :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)}
|
||||
if @current_build_status == "success"
|
||||
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)}
|
||||
elsif @current_build_status == "failure"
|
||||
format.html
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -145,7 +149,7 @@ class QualityAnalysisController < ApplicationController
|
|||
get_current_build_status = @client.job.get_current_build_status("Hjqreturn-1280")
|
||||
logger.error("Failed to update job: ==> #{jenkins_job}") unless jenkins_job == '200'
|
||||
|
||||
# 数据更新到Trustie数据库
|
||||
# 数据更新到Trustie数据
|
||||
if jenkins_job == '200'
|
||||
logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}")
|
||||
@quality_analysis.path = path
|
||||
|
@ -168,18 +172,12 @@ class QualityAnalysisController < ApplicationController
|
|||
@branch = params[:branch]
|
||||
@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
|
||||
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
||||
@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')["output"]
|
||||
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
|
||||
|
@ -188,7 +186,6 @@ class QualityAnalysisController < ApplicationController
|
|||
rescue => e
|
||||
puts e
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Find project of id params[:project_id]
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<% if @current_build_status == "success" %>
|
||||
<%= render :partial => "show", :locals => {:branch => params[:branch]} %>
|
||||
<% else %>
|
||||
<% if @build_console_result %>
|
||||
运行结果超时
|
||||
<% else %>
|
||||
<%= render :partial => "console_output" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2" style="width:180px;">质量分析</h2>
|
||||
</div>
|
||||
<div>
|
||||
<div class="c_red">本次分析失败,原因如下:</div>
|
||||
<% if @current_build_status == "failure" %>
|
||||
<%= h @console_build.to_json %>
|
||||
<% elsif @build_console_result == false %>
|
||||
分析超时
|
||||
<% end %>
|
||||
</div>
|
|
@ -15,7 +15,7 @@
|
|||
<%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"]), :id => 'branch', :class => "analysis-option-box" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#ajax-indicator').text('正在分析中…………(大概需要30分钟,请耐心等待)').show();$('#quality_analyses_form').submit();hideModal()">提交</a></div>
|
||||
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#ajax-indicator').css('opacity','0.8').text('正在分析中…………(大概需要30分钟,请耐心等待)').show();$('#quality_analyses_form').submit();hideModal()">提交</a></div>
|
||||
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal()">取消</a></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -246,7 +246,7 @@ a.c_green{ color:#28be6c;}
|
|||
.b_blue{background:#64bdd9;}
|
||||
.b_green{background:#28be6c;}
|
||||
.b_slow_yellow{background:#adde18;}
|
||||
.b_yellow{background:#DDDF0D;}
|
||||
.b_yellow{background:#e4de4b;}
|
||||
.b_slow_red{background:#df8538;}
|
||||
.b_green2 {background:#63c360;}
|
||||
.b_red {background:#d60308;}
|
||||
|
@ -1184,4 +1184,4 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px;
|
|||
.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
|
||||
|
||||
/*20160622代码分析弹窗*/
|
||||
.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
|
||||
.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
|
||||
|
|
Loading…
Reference in New Issue