stable version for sonar
This commit is contained in:
parent
dee53a1383
commit
9e7cde6056
|
@ -30,20 +30,20 @@ class QualityAnalysisController < ApplicationController
|
|||
sonar.sources=#{path}
|
||||
sonar.language=#{language.downcase}
|
||||
sonar.sourceEncoding=utf-8"
|
||||
git_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier+"."+"git"
|
||||
git_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git"
|
||||
|
||||
|
||||
# # modify config
|
||||
# # # modify config
|
||||
@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.BranchSpec/name").content = "*/#{branch}"
|
||||
@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)
|
||||
# relace gitlab hook
|
||||
# genkins address
|
||||
@g.add_project_hook(@project.gpid,"http://123.59.135.93:8890/project/#{user_name}_#{identifier}")
|
||||
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier)
|
||||
end
|
||||
|
||||
def index
|
||||
|
|
|
@ -30,13 +30,13 @@ class RepositoriesController < ApplicationController
|
|||
menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
|
||||
default_search_scope :changesets
|
||||
|
||||
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analyses]
|
||||
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis]
|
||||
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
|
||||
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive]
|
||||
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive, :quality_analyses]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive, :quality_analysis]
|
||||
# 链接gitlab
|
||||
before_filter :connect_gitlab, :only => [:quality_analyses]
|
||||
before_filter :connect_gitlab, :only => [:quality_analysis]
|
||||
accept_rss_auth :revisions
|
||||
# hidden repositories filter // 隐藏代码过滤器
|
||||
before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ]
|
||||
|
@ -309,7 +309,7 @@ update
|
|||
end
|
||||
end
|
||||
|
||||
def quality_analyses
|
||||
def quality_analysis
|
||||
gitlab_branches = @g.branches(@project.gpid)
|
||||
@branch_names = gitlab_branches.map{|b| b.name}
|
||||
@gitlab_default_branch = @g.project(@project.gpid).default_branch
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class QualityAnalysis < ActiveRecord::Base
|
||||
attr_accessible :author_login, :project_id, :rep_identifier
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
<%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id), :remote => true , :class => 'resourcesSearchloadBox mt10', :id => 'quality_analyses_form') do %>
|
||||
<%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier), :remote => true , :class => 'resourcesSearchloadBox mt10', :id => 'quality_analyses_form') do %>
|
||||
<textarea id="path_description" name="path" rows="8" placeholder="目录相当于根目录,用半逗号隔开。如:src/main/java,libs"></textarea>
|
||||
<%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch' %>
|
||||
<%= select_tag :language, options_for_select(["Java","C","PHP", "Web"]), :id => 'branch' %>
|
|
@ -1,4 +1,4 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'repositories/quality_analyses', :locals => {}) %>');
|
||||
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'repositories/quality_analysis', :locals => {}) %>');
|
||||
showModal('ajax-modal', '615px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal()' style='margin-left: 580px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
|
|
@ -2,7 +2,7 @@
|
|||
<div class="project_r_h">
|
||||
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
|
||||
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
|
||||
<%= link_to "质量分析", quality_analyses_path(:id => @project.id, :repository_id => @repository.identifier), :remote => true, :class => "btn_zipdown fr" %>
|
||||
<%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier), :remote => true, :class => "btn_zipdown fr" %>
|
||||
|
||||
</div>
|
||||
<div class="repository_con" style="line-height:1.9;">
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class CreateQualityAnalyses < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :quality_analyses do |t|
|
||||
t.integer :project_id
|
||||
t.string :author_login
|
||||
t.string :rep_identifier
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160613065840) do
|
||||
ActiveRecord::Schema.define(:version => 20160622015019) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1833,6 +1833,14 @@ ActiveRecord::Schema.define(:version => 20160613065840) do
|
|||
|
||||
add_index "protected_branches", ["project_id"], :name => "index_protected_branches_on_project_id"
|
||||
|
||||
create_table "quality_analyses", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.string "author_login"
|
||||
t.string "rep_identifier"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "queries", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.string "name", :default => "", :null => false
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :quality_analyasis, class: 'QualityAnalysis' do
|
||||
project_id 1
|
||||
author_login "MyString"
|
||||
rep_identifier "MyString"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe QualityAnalysis, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue