Commit 1d3a66bc5b372245417111778f15f617b8e9b116
1 parent
0de5286e
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
adding jenkins hook
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 | 25 | if allow_jenkins_integration |
26 | 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 | + gitlab_integration.create_jenkins_hook(jenkins_integration.project_url) | |
28 | 29 | end |
30 | + | |
29 | 31 | end |
30 | 32 | end |
31 | 33 | ... | ... |
plugins/serpro_integration/lib/serpro_integration_plugin/gitlab_integration.rb
... | ... | @@ -4,12 +4,15 @@ class SerproIntegrationPlugin::GitlabIntegration |
4 | 4 | |
5 | 5 | def initialize(host, private_token) |
6 | 6 | @client = Gitlab.client(:endpoint => host, :private_token => private_token) |
7 | + @group = nil | |
8 | + @project = nil | |
7 | 9 | end |
8 | 10 | |
9 | 11 | def create_group(group_name) |
10 | 12 | #FIXME find group by name |
11 | 13 | group = @client.groups.select {|group| group.name == group_name}.first |
12 | 14 | group ||= @client.create_group(group_name, group_name) |
15 | + @group = group | |
13 | 16 | end |
14 | 17 | |
15 | 18 | def create_project(project_name, group) |
... | ... | @@ -31,7 +34,7 @@ class SerproIntegrationPlugin::GitlabIntegration |
31 | 34 | #Create Web Hook for Jenkins' integration |
32 | 35 | #Gitlab.add_project_hook(project.id, "#{self.jenkins[:url]}/gitlab/build_now") |
33 | 36 | end |
34 | - project | |
37 | + @project = project | |
35 | 38 | end |
36 | 39 | |
37 | 40 | def create_user(email, group) |
... | ... | @@ -59,4 +62,9 @@ class SerproIntegrationPlugin::GitlabIntegration |
59 | 62 | project = create_project(profile.gitlab_project_name, group) |
60 | 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 | 70 | end | ... | ... |
plugins/serpro_integration/lib/serpro_integration_plugin/jenkins_integration.rb
... | ... | @@ -5,10 +5,17 @@ class SerproIntegrationPlugin::JenkinsIntegration |
5 | 5 | |
6 | 6 | def initialize(host, private_token, user) |
7 | 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 | 14 | end |
9 | 15 | |
10 | 16 | #FIXME make jenkins integration works |
11 | 17 | def create_jenkis_project(profile, repository_path, web_url, git_url) |
18 | + @profile = profile | |
12 | 19 | #begin |
13 | 20 | project_name = repository_path.split('/').last |
14 | 21 | if @client.job.list(project_name).blank? | ... | ... |