some modified

This commit is contained in:
Your Name 2016-06-24 21:33:35 +08:00
parent 4a4c613c55
commit 69f7dab04d
2 changed files with 14 additions and 4 deletions

View File

@ -21,11 +21,11 @@ class QualityAnalysisController < ApplicationController
#@client.exists?(job_name)
@g = Gitlab.client
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]
path = params[:path]
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
properties = "sonar.projectKey=#{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
#
# 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
# genkins address
@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)
else
qa.update_attribute(:sonar_version, version)
end
# scan
@client.job.build("#{user_name}_#{identifier}")
end
def index

View File

@ -20,6 +20,8 @@ require 'SVG/Graph/BarHorizontal'
require 'digest/sha1'
require 'redmine/scm/adapters/abstract_adapter'
require 'tempfile'
require 'json'
require 'open-uri'
class ChangesetNotFound < Exception; end
class InvalidRevisionParam < Exception; end
@ -358,6 +360,11 @@ update
end
def show
# sonar_address = Redmine::Configuration['sonar_address']
# projects_date = open(sonar_address + "/api/projects/index").read
# arr = JSON.parse(projects_date).map {|m| m["nm"]}
# arr.map
## TODO: the below will move to filter, done.
if !User.current.member_of?(@project) && @project.hidden_repo
render_403