Merge branch 'rep_quality' of https://git.trustie.net/jacknudt/trustieforge into rep_quality
Conflicts: app/views/repositories/_quality_analyses.html.erb
This commit is contained in:
commit
dee53a1383
|
@ -1,46 +1,55 @@
|
||||||
class QualityAnalysisController < ApplicationController
|
class QualityAnalysisController < ApplicationController
|
||||||
before_filter :find_project_by_project_id#, :except => [:getattachtype]
|
before_filter :find_project_by_project_id#, :except => [:getattachtype]
|
||||||
|
before_filter :authorize
|
||||||
layout "base_projects"
|
layout "base_projects"
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
require 'jenkins_api_client'
|
require 'jenkins_api_client'
|
||||||
require 'nokogiri'
|
require 'nokogiri'
|
||||||
|
require 'json'
|
||||||
|
require 'open-uri'
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@client = JenkinsApi::Client.new(:server_url => 'http://123.59.135.93:8890',
|
||||||
|
:username => "temp",
|
||||||
|
:password => '123123')
|
||||||
|
#@client.exists?(job_name)
|
||||||
|
@g = Gitlab.client
|
||||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||||
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].nil? ? "master" : params[:branch]
|
||||||
language = params[:language]
|
language = params[:language]
|
||||||
path = params[:path]
|
path = params[:path]
|
||||||
properties = "sonar.projectKey=#{user_name}:#{@project.name}
|
identifier = params[:identifier]
|
||||||
sonar.projectName=My #{@project.name}
|
properties = "sonar.projectKey=#{user_name}:#{identifier}
|
||||||
sonar.projectVersion=1.11
|
sonar.projectName=#{user_name}:#{identifier}
|
||||||
|
sonar.projectVersion=1.0
|
||||||
sonar.sources=#{path}
|
sonar.sources=#{path}
|
||||||
sonar.language=#{language}
|
sonar.language=#{language.downcase}
|
||||||
sonar.sourceEncoding=utf-8"
|
sonar.sourceEncoding=utf-8"
|
||||||
git_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git"
|
git_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier+"."+"git"
|
||||||
@client = JenkinsApi::Client.new(:server_url => 'http://123.59.135.93:8890',
|
|
||||||
:username => user_name,
|
|
||||||
:password => '')
|
|
||||||
|
|
||||||
# modify config
|
|
||||||
|
# # modify config
|
||||||
@doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml')))
|
@doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml')))
|
||||||
@doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url
|
@doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url
|
||||||
@doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}"
|
@doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}"
|
||||||
@doc.at_xpath("//hudson.plugins.git.BranchSpec/properties").content = properties
|
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties #sonar-properties
|
||||||
sonar_properties = @doc.xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").text #sonar-properties
|
|
||||||
|
|
||||||
# replace config.xml of jenkins
|
# replace config.xml of jenkins
|
||||||
@client = @client.job.create("tesc_create", File.read(File.join(Rails.root, 'tmp', 'config.xml')))
|
@client = @client.job.create("#{user_name}_#{identifier}", @doc.to_xml)
|
||||||
|
# relace gitlab hook
|
||||||
|
# genkins address
|
||||||
|
@g.add_project_hook(@project.gpid,"http://123.59.135.93:8890/project/#{user_name}_#{identifier}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
data = open('http://123.59.135.93:8891/api/resources/index?resource=my:project985&depth=-1&metrics=complexity,class_complexity,lines,comment_lines,blocker_violations').read
|
||||||
|
cc=JSON.parse(data)
|
||||||
|
p cc
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find project of id params[:project_id]
|
# Find project of id params[:project_id]
|
||||||
|
@ -49,4 +58,14 @@ class QualityAnalysisController < ApplicationController
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Authorize the user for the requested action
|
||||||
|
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
||||||
|
unless @project.archived? && @project.gpid.nil?
|
||||||
|
true
|
||||||
|
else
|
||||||
|
render_403 :message => :notice_not_authorized_archived_project
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
69
config.xml
69
config.xml
|
@ -1,69 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<project>
|
|
||||||
<actions/>
|
|
||||||
<description></description>
|
|
||||||
<keepDependencies>false</keepDependencies>
|
|
||||||
<properties>
|
|
||||||
<com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab-plugin@1.2.3">
|
|
||||||
<gitLabConnection>trustie-gitlab</gitLabConnection>
|
|
||||||
</com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>
|
|
||||||
</properties>
|
|
||||||
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.4.4">
|
|
||||||
<configVersion>2</configVersion>
|
|
||||||
<userRemoteConfigs>
|
|
||||||
<hudson.plugins.git.UserRemoteConfig>
|
|
||||||
<url>http://192.168.8.158:8889/root/badboy.git</url>
|
|
||||||
</hudson.plugins.git.UserRemoteConfig>
|
|
||||||
</userRemoteConfigs>
|
|
||||||
<branches>
|
|
||||||
<hudson.plugins.git.BranchSpec>
|
|
||||||
<name>*/master</name>
|
|
||||||
</hudson.plugins.git.BranchSpec>
|
|
||||||
</branches>
|
|
||||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
|
||||||
<submoduleCfg class="list"/>
|
|
||||||
<extensions/>
|
|
||||||
</scm>
|
|
||||||
<canRoam>true</canRoam>
|
|
||||||
<disabled>false</disabled>
|
|
||||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
|
||||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
|
||||||
<triggers>
|
|
||||||
<com.dabsquared.gitlabjenkins.GitLabPushTrigger plugin="gitlab-plugin@1.2.3">
|
|
||||||
<spec></spec>
|
|
||||||
<triggerOnPush>true</triggerOnPush>
|
|
||||||
<triggerOnMergeRequest>true</triggerOnMergeRequest>
|
|
||||||
<triggerOpenMergeRequestOnPush>never</triggerOpenMergeRequestOnPush>
|
|
||||||
<ciSkip>true</ciSkip>
|
|
||||||
<setBuildDescription>true</setBuildDescription>
|
|
||||||
<addNoteOnMergeRequest>true</addNoteOnMergeRequest>
|
|
||||||
<addCiMessage>false</addCiMessage>
|
|
||||||
<addVoteOnMergeRequest>true</addVoteOnMergeRequest>
|
|
||||||
<branchFilterType>All</branchFilterType>
|
|
||||||
<includeBranchesSpec></includeBranchesSpec>
|
|
||||||
<excludeBranchesSpec></excludeBranchesSpec>
|
|
||||||
<targetBranchRegex></targetBranchRegex>
|
|
||||||
<acceptMergeRequestOnSuccess>false</acceptMergeRequestOnSuccess>
|
|
||||||
</com.dabsquared.gitlabjenkins.GitLabPushTrigger>
|
|
||||||
</triggers>
|
|
||||||
<concurrentBuild>false</concurrentBuild>
|
|
||||||
<builders>
|
|
||||||
<hudson.plugins.sonar.SonarRunnerBuilder plugin="sonar@2.4.2">
|
|
||||||
<project></project>
|
|
||||||
<properties>
|
|
||||||
sonar.projectKey=my:project985
|
|
||||||
sonar.projectName=My project985
|
|
||||||
sonar.projectVersion=1.11
|
|
||||||
sonar.sources=src
|
|
||||||
sonar.language=java
|
|
||||||
sonar.sourceEncoding=utf-8
|
|
||||||
</properties>
|
|
||||||
<javaOpts></javaOpts>
|
|
||||||
<additionalArguments></additionalArguments>
|
|
||||||
<jdk>(Inherit From Job)</jdk>
|
|
||||||
<task></task>
|
|
||||||
</hudson.plugins.sonar.SonarRunnerBuilder>
|
|
||||||
</builders>
|
|
||||||
<publishers/>
|
|
||||||
<buildWrappers/>
|
|
||||||
</project>
|
|
Loading…
Reference in New Issue