community.rb
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require_dependency 'community'
class Community
settings_items :allow_sonar_integration, :type => :boolean, :default => true
settings_items :allow_gitlab_integration, :type => :boolean, :default => true
settings_items :allow_jenkins_integration, :type => :boolean, :default => true
#FIXME make test for default option
settings_items :serpro_integration_plugin, :type => Hash, :default => {}
attr_accessible :allow_unauthenticated_comments, :allow_gitlab_integration, :gitlab, :allow_sonar_integration, :sonar, :allow_jenkins_integration, :jenkins
after_update :create_integration_projects
def create_integration_projects
gitlab_project = SerproIntegrationPlugin::GitlabIntegration.create_gitlab_project(self)
SerproIntegrationPlugin::JenkinsIntegration.create_jenkis_project(self, jenkins_project_name, gitlab_project.path_with_namespace, gitlab_project.web_url, gitlab_project.http_url_to_repo)
end
def serpro_integration_plugin_settings
@settings ||= Noosfero::Plugin::Settings.new(environment, SerproIntegrationPlugin)
end
def gitlab= params
self.serpro_integration_plugin[:gitlab] = params
end
def gitlab
self.serpro_integration_plugin[:gitlab] ||= {}
end
def gitlab_project_name
gitlab[:project_name] || self.identifier
end
def gitlab_host
serpro_integration_plugin_settings.gitlab[:host]
end
def gitlab_private_token
serpro_integration_plugin_settings.gitlab[:private_token]
end
def sonar= params
self.serpro_integration_plugin[:sonar] = params
end
def sonar
self.serpro_integration_plugin[:sonar] ||= {}
end
def jenkins= params
self.serpro_integration_plugin[:jenkins] = params
end
def jenkins
self.serpro_integration_plugin[:jenkins] ||= {}
end
def jenkins_project_name
jenkins[:project_name] || self.identifier
end
end