Commit e57b93927e3af0897c27bf50b068daad90079834

Authored by Leandro Santos
2 parents df1e0ebe 43924df5

Merge branches 'rails3_AI3033-serpro_integration' and 'rails3_stable' into rails3_stable

plugins/serpro_integration/lib/ext/community.rb
@@ -24,8 +24,9 @@ class Community @@ -24,8 +24,9 @@ class Community
24 24
25 if allow_jenkins_integration 25 if allow_jenkins_integration
26 jenkins_integration = SerproIntegrationPlugin::JenkinsIntegration.new(jenkins_host, jenkins_private_token, jenkins_user) 26 jenkins_integration = SerproIntegrationPlugin::JenkinsIntegration.new(jenkins_host, jenkins_private_token, jenkins_user)
  27 +
27 jenkins_integration.create_jenkis_project(self, gitlab_project.path_with_namespace, gitlab_project.web_url, gitlab_project.http_url_to_repo) 28 jenkins_integration.create_jenkis_project(self, gitlab_project.path_with_namespace, gitlab_project.web_url, gitlab_project.http_url_to_repo)
28 - gitlab_integration.create_jenkins_hook(jenkins_integration.project_url) 29 + gitlab_integration.create_jenkins_hook(jenkins_integration.host)
29 end 30 end
30 31
31 end 32 end
plugins/serpro_integration/lib/ext/profile.rb
@@ -1,9 +0,0 @@ @@ -1,9 +0,0 @@
1 -require_dependency 'profile'  
2 -  
3 -class Profile  
4 - settings_items :allow_sonar_integration, :type => :boolean, :default => false  
5 - settings_items :allow_gitlab_integration, :type => :boolean, :default => false  
6 -  
7 - #FIXME make test for default option  
8 - settings_items :serpro_integration_plugin, :type => Hash, :default => {}  
9 -end  
plugins/serpro_integration/lib/serpro_integration_plugin/gitlab_integration.rb
@@ -63,8 +63,8 @@ class SerproIntegrationPlugin::GitlabIntegration @@ -63,8 +63,8 @@ class SerproIntegrationPlugin::GitlabIntegration
63 end 63 end
64 64
65 65
66 - def create_jenkins_hook(jenkins_project_url)  
67 - @client.add_project_hook(@project.id, "#{jenkins_project_url}/gitlab/build_now") 66 + def create_jenkins_hook(jenkins_host)
  67 + @client.add_project_hook(@project.id, "#{jenkins_host}/gitlab/build_now")
68 end 68 end
69 69
70 end 70 end
plugins/serpro_integration/lib/serpro_integration_plugin/jenkins_integration.rb
@@ -3,21 +3,29 @@ require 'jenkins_api_client' @@ -3,21 +3,29 @@ require 'jenkins_api_client'
3 3
4 class SerproIntegrationPlugin::JenkinsIntegration 4 class SerproIntegrationPlugin::JenkinsIntegration
5 5
  6 + attr_accessor :profile
  7 +
6 def initialize(host, private_token, user) 8 def initialize(host, private_token, user)
7 @client = JenkinsApi::Client.new(:server_url => host, :password => private_token, :username => user) 9 @client = JenkinsApi::Client.new(:server_url => host, :password => private_token, :username => user)
8 @profile = nil 10 @profile = nil
9 - 11 + @private_token = private_token
10 end 12 end
11 13
12 def project_url 14 def project_url
13 - "#{jenkins_host}/#{jenkins_project_name}" 15 + "#{host}/#{project_name}"
14 end 16 end
15 17
  18 + def host
  19 + @profile.jenkins_host
  20 + end
  21 +
  22 + def project_name
  23 + @profile.jenkins_project_name
  24 + end
16 #FIXME make jenkins integration works 25 #FIXME make jenkins integration works
17 def create_jenkis_project(profile, repository_path, web_url, git_url) 26 def create_jenkis_project(profile, repository_path, web_url, git_url)
18 @profile = profile 27 @profile = profile
19 #begin 28 #begin
20 - project_name = repository_path.split('/').last  
21 if @client.job.list(project_name).blank? 29 if @client.job.list(project_name).blank?
22 @client.job.create(profile.jenkins_project_name, xml_jenkins(repository_path, web_url, git_url)) 30 @client.job.create(profile.jenkins_project_name, xml_jenkins(repository_path, web_url, git_url))
23 end 31 end