|
|
@ -21,11 +21,11 @@ class QualityAnalysisController < ApplicationController
|
|
|
|
#@client.exists?(job_name)
|
|
|
|
#@client.exists?(job_name)
|
|
|
|
@g = Gitlab.client
|
|
|
|
@g = Gitlab.client
|
|
|
|
user_name = User.find(params[:user_id]).try(:login)
|
|
|
|
user_name = User.find(params[:user_id]).try(:login)
|
|
|
|
branch = params[:branch].nil? ? "master" : params[:branch]
|
|
|
|
branch = params[:branch].blank? ? "master" : params[:branch]
|
|
|
|
language = params[:language]
|
|
|
|
language = params[:language]
|
|
|
|
path = params[:path]
|
|
|
|
path = params[:path]
|
|
|
|
identifier = params[:identifier]
|
|
|
|
identifier = params[:identifier]
|
|
|
|
qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first
|
|
|
|
qa = QualityAnalysis.where(:project_id => @project.id).first
|
|
|
|
version = qa.nil? ? 1 : qa.sonar_version + 1
|
|
|
|
version = qa.nil? ? 1 : qa.sonar_version + 1
|
|
|
|
properties = "sonar.projectKey=#{user_name}:#{identifier}
|
|
|
|
properties = "sonar.projectKey=#{user_name}:#{identifier}
|
|
|
|
sonar.projectName=#{user_name}:#{identifier}
|
|
|
|
sonar.projectName=#{user_name}:#{identifier}
|
|
|
@ -42,16 +42,19 @@ class QualityAnalysisController < ApplicationController
|
|
|
|
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties #sonar-properties
|
|
|
|
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties #sonar-properties
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# replace config.xml of jenkins
|
|
|
|
# replace config.xml of jenkins
|
|
|
|
@client = @client.job.create("#{user_name}_#{identifier}", @doc.to_xml)
|
|
|
|
@client.job.create("#{user_name}_#{identifier}", @doc.to_xml)
|
|
|
|
# relace gitlab hook
|
|
|
|
# relace gitlab hook
|
|
|
|
# genkins address
|
|
|
|
# genkins address
|
|
|
|
@g.add_project_hook(@project.gpid, jenkins_address + "/project/#{user_name}_#{identifier}")
|
|
|
|
@g.add_project_hook(@project.gpid, jenkins_address + "/project/#{user_name}_#{identifier}")
|
|
|
|
if qa.nil?
|
|
|
|
if qa.blank?
|
|
|
|
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, :sonar_version => version, :path => path, :branch => branch, :language => language)
|
|
|
|
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, :sonar_version => version, :path => path, :branch => branch, :language => language)
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
qa.update_attribute(:sonar_version, version)
|
|
|
|
qa.update_attribute(:sonar_version, version)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# scan
|
|
|
|
|
|
|
|
@client.job.build("#{user_name}_#{identifier}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
def index
|
|
|
|