Commit 41c859e789184b9d928749e6e233069ed99446fb
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branches 'rails3_AI3033-serpro_integration' and 'rails3_stable' into rails3_stable
Showing
3 changed files
with
18 additions
and
1 deletions
Show diff stats
plugins/serpro_integration/lib/ext/community.rb
| @@ -25,7 +25,9 @@ class Community | @@ -25,7 +25,9 @@ class Community | ||
| 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 | jenkins_integration.create_jenkis_project(self, gitlab_project.path_with_namespace, gitlab_project.web_url, gitlab_project.http_url_to_repo) | 27 | 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) | ||
| 28 | end | 29 | end |
| 30 | + | ||
| 29 | end | 31 | end |
| 30 | end | 32 | end |
| 31 | 33 |
plugins/serpro_integration/lib/serpro_integration_plugin/gitlab_integration.rb
| @@ -4,12 +4,15 @@ class SerproIntegrationPlugin::GitlabIntegration | @@ -4,12 +4,15 @@ class SerproIntegrationPlugin::GitlabIntegration | ||
| 4 | 4 | ||
| 5 | def initialize(host, private_token) | 5 | def initialize(host, private_token) |
| 6 | @client = Gitlab.client(:endpoint => host, :private_token => private_token) | 6 | @client = Gitlab.client(:endpoint => host, :private_token => private_token) |
| 7 | + @group = nil | ||
| 8 | + @project = nil | ||
| 7 | end | 9 | end |
| 8 | 10 | ||
| 9 | def create_group(group_name) | 11 | def create_group(group_name) |
| 10 | #FIXME find group by name | 12 | #FIXME find group by name |
| 11 | group = @client.groups.select {|group| group.name == group_name}.first | 13 | group = @client.groups.select {|group| group.name == group_name}.first |
| 12 | group ||= @client.create_group(group_name, group_name) | 14 | group ||= @client.create_group(group_name, group_name) |
| 15 | + @group = group | ||
| 13 | end | 16 | end |
| 14 | 17 | ||
| 15 | def create_project(project_name, group) | 18 | def create_project(project_name, group) |
| @@ -31,7 +34,7 @@ class SerproIntegrationPlugin::GitlabIntegration | @@ -31,7 +34,7 @@ class SerproIntegrationPlugin::GitlabIntegration | ||
| 31 | #Create Web Hook for Jenkins' integration | 34 | #Create Web Hook for Jenkins' integration |
| 32 | #Gitlab.add_project_hook(project.id, "#{self.jenkins[:url]}/gitlab/build_now") | 35 | #Gitlab.add_project_hook(project.id, "#{self.jenkins[:url]}/gitlab/build_now") |
| 33 | end | 36 | end |
| 34 | - project | 37 | + @project = project |
| 35 | end | 38 | end |
| 36 | 39 | ||
| 37 | def create_user(email, group) | 40 | def create_user(email, group) |
| @@ -59,4 +62,9 @@ class SerproIntegrationPlugin::GitlabIntegration | @@ -59,4 +62,9 @@ class SerproIntegrationPlugin::GitlabIntegration | ||
| 59 | project = create_project(profile.gitlab_project_name, group) | 62 | project = create_project(profile.gitlab_project_name, group) |
| 60 | end | 63 | end |
| 61 | 64 | ||
| 65 | + | ||
| 66 | + def create_jenkins_hook(jenkins_project_url) | ||
| 67 | + @client.add_project_hook(@project.id, "#{jenkins_project_url}/gitlab/build_now") | ||
| 68 | + end | ||
| 69 | + | ||
| 62 | end | 70 | end |
plugins/serpro_integration/lib/serpro_integration_plugin/jenkins_integration.rb
| @@ -5,10 +5,17 @@ class SerproIntegrationPlugin::JenkinsIntegration | @@ -5,10 +5,17 @@ class SerproIntegrationPlugin::JenkinsIntegration | ||
| 5 | 5 | ||
| 6 | def initialize(host, private_token, user) | 6 | def initialize(host, private_token, user) |
| 7 | @client = JenkinsApi::Client.new(:server_url => host, :password => private_token, :username => user) | 7 | @client = JenkinsApi::Client.new(:server_url => host, :password => private_token, :username => user) |
| 8 | + @profile = nil | ||
| 9 | + | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + def project_url | ||
| 13 | + "#{jenkins_host}/#{jenkins_project_name}" | ||
| 8 | end | 14 | end |
| 9 | 15 | ||
| 10 | #FIXME make jenkins integration works | 16 | #FIXME make jenkins integration works |
| 11 | def create_jenkis_project(profile, repository_path, web_url, git_url) | 17 | def create_jenkis_project(profile, repository_path, web_url, git_url) |
| 18 | + @profile = profile | ||
| 12 | #begin | 19 | #begin |
| 13 | project_name = repository_path.split('/').last | 20 | project_name = repository_path.split('/').last |
| 14 | if @client.job.list(project_name).blank? | 21 | if @client.job.list(project_name).blank? |