ucb_deployer 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ucb_deployer (1.0.1)
4
+ ucb_deployer (1.0.0)
5
5
  rake (= 0.8.7)
6
6
 
7
7
  GEM
@@ -0,0 +1,34 @@
1
+ module UcbDeployer::ConfigTasks
2
+ module Jira
3
+ class ConfigAppProperties
4
+
5
+ def initialize(config)
6
+ @config= config
7
+ end
8
+
9
+ def execute()
10
+ file_data = File.readlines(self.jira_app_properties_path()).map do |line|
11
+ if /(#{Regexp.quote(self.jira_home_token())})/.match(line)
12
+ "#{self.jira_home_token()} #{@config.data_dir()}"
13
+ else
14
+ line
15
+ end
16
+ end
17
+
18
+ File.open(self.jira_app_properties_path(), "w") do |io|
19
+ file_data.each { |line| io.puts(line) }
20
+ end
21
+ end
22
+
23
+
24
+ def jira_home_token()
25
+ "jira.home ="
26
+ end
27
+
28
+ def jira_app_properties_path()
29
+ "#{@config.build_dir()}/src/edit-webapp/WEB-INF/classes/jira-application.properties"
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,76 @@
1
+ module UcbDeployer::ConfigTasks
2
+ module Jira
3
+ class ConfigCasAuth
4
+
5
+ def initialize(config)
6
+ @config = config
7
+ end
8
+
9
+ def execute()
10
+ self.update_seraph_config_xml()
11
+ self.update_web_xml()
12
+ end
13
+
14
+
15
+ def seraph_config_path()
16
+ "#{@config.build_dir()}/src/webapp/WEB-INF/classes/seraph-config.xml"
17
+ end
18
+
19
+ def seraph_config_auth_token()
20
+ "com.atlassian.jira.security.login.JiraSeraphAuthenticator"
21
+ end
22
+
23
+ def seraph_config_logout_url_token()
24
+ "/secure/Logout!default.jspa"
25
+ end
26
+
27
+ def cas_authenticator_class()
28
+ "org.soulwing.cas.apps.atlassian.JiraCasAuthenticator"
29
+ end
30
+
31
+ def cas_logout_url()
32
+ "/casLogout.action"
33
+ end
34
+
35
+ def web_xml_path()
36
+ "#{@config.build_dir()}/src/webapp/WEB-INF/web.xml"
37
+ end
38
+
39
+ def web_xml_token()
40
+ "<!--This filter is used to determine is there are any Application Errors before any pages are accessed"
41
+ end
42
+
43
+ def update_seraph_config_xml()
44
+ seraph_xml_data = File.readlines(self.seraph_config_path()).map do |line|
45
+ if m = /(#{Regexp.quote(self.seraph_config_auth_token())})/.match(line)
46
+ "#{m.pre_match}#{self.cas_authenticator_class()}#{m.post_match}"
47
+ elsif m = /(#{Regexp.quote(self.seraph_config_logout_url_token())})/.match(line)
48
+ "#{m.pre_match}#{@config.cas_server_url()}/logout#{m.post_match}"
49
+ else
50
+ line
51
+ end
52
+ end
53
+
54
+ File.open(self.seraph_config_path(), "w") do |io|
55
+ seraph_xml_data.each { |line| io.puts(line) }
56
+ end
57
+ end
58
+
59
+ def update_web_xml()
60
+ web_xml_data = File.readlines(self.web_xml_path()).map do |line|
61
+ if line =~ /#{web_xml_token}/
62
+ template = File.open("#{@config.resources_dir()}/jira_cas_web.xml") { |f| f.read() }
63
+ line + ERB.new(template).result(@config.send(:binding))
64
+ else
65
+ line
66
+ end
67
+ end
68
+
69
+ File.open(self.web_xml_path(), "w") do |io|
70
+ web_xml_data.each { |line| io.puts(line) }
71
+ end
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,19 @@
1
+ ##
2
+ # Places IST banner jpg in images directory
3
+ #
4
+ module UcbDeployer::ConfigTasks
5
+ module Jira
6
+ class ConfigIstBanner
7
+
8
+ def initialize(config)
9
+ @config = config
10
+ end
11
+
12
+ def execute()
13
+ FileUtils.cp("#{UcbDeployer::RESOURCES_DIR}/ist_banner.jpg",
14
+ "#{@config.build_dir()}/src/webapp/images/")
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ module UcbDeployer::ConfigTasks
2
+ module Jira
3
+ class ConfigJiraConfigProperties
4
+
5
+ def initialize(config)
6
+ @config = config
7
+ end
8
+
9
+ def execute()
10
+ File.open(self.jira_config_properties_path(), "w") do |fd|
11
+ fd.puts(self.projectkey_config())
12
+ end
13
+ end
14
+
15
+
16
+ def projectkey_config()
17
+ "jira.projectkey.pattern = ([A-Z][A-Z0-9]+)"
18
+ end
19
+
20
+ def jira_config_properties_path()
21
+ "#{@config.data_dir()}/jira-config.properties"
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ ##
2
+ # Remove jars from WEB-INF/lib that have been installed at the container
3
+ # level to avoid conflicts.
4
+ #
5
+ module UcbDeployer::ConfigTasks
6
+ module Jira
7
+ class RemoveConflictingJarFiles
8
+
9
+ def initialize(config)
10
+ @config = config
11
+ end
12
+
13
+ def execute()
14
+ FileUtils.mkdir_p("#{@config.build_dir()}/src/edit-webapp/WEB-INF/lib/")
15
+ FileUtils.cp(Dir["#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*"],
16
+ "#{@config.build_dir()}/src/edit-webapp/WEB-INF/lib/")
17
+
18
+ # These have been placed in $CATALINA_HOME/lib
19
+ ["mail", "activation", "javamail", "commons-logging", "log4j"].each do |jar_file|
20
+ FileUtils.rm_rf(Dir["#{@config.build_dir()}/src/webapp/WEB-INF/lib/#{jar_file}-*"])
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -2,7 +2,7 @@
2
2
  module UcbDeployer
3
3
  class ConfluenceDeployer < Deployer
4
4
 
5
- def initialize(config_file = "#{ENV['HOME']}/.ucb_deployer/config/confluence/deploy.yml")
5
+ def initialize(config_file = "#{ENV['HOME']}/config/confluence/deploy.yml")
6
6
  debug("Using config file: #{config_file}")
7
7
  debug("")
8
8
  load_config(config_file)
@@ -24,18 +24,23 @@ module UcbDeployer
24
24
 
25
25
 
26
26
  def export()
27
+ raise NotImplementedError
27
28
  end
28
29
 
29
30
  def configure()
31
+ raise NotImplementedError
30
32
  end
31
33
 
32
34
  def build()
35
+ raise NotImplementedError
33
36
  end
34
37
 
35
38
  def rollback()
39
+ raise NotImplementedError
36
40
  end
37
41
 
38
42
  def deploy()
43
+ raise NotImplementedError
39
44
  end
40
45
 
41
46
  ##
@@ -66,7 +71,15 @@ module UcbDeployer
66
71
  end
67
72
  end
68
73
  end
69
-
74
+
75
+ def deployer_home()
76
+ ::UcbDeployer::DEPLOYER_HOME
77
+ end
78
+
79
+ def resources_dir()
80
+ ::UcbDeployer::RESOURCES_DIR
81
+ end
82
+
70
83
  def debug(str)
71
84
  UcbDeployer.debug(str)
72
85
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module UcbDeployer
3
2
  class JiraDeployer < Deployer
4
3
 
@@ -19,16 +18,14 @@ module UcbDeployer
19
18
 
20
19
  def configure()
21
20
  self.info("Configuring application.")
22
- self.config_web_xml()
23
- self.config_seraph_config_xml()
24
- self.config_entityengine_xml()
25
- self.config_jira_application_properties()
26
- self.config_ist_banner()
27
- self.reshuffle_jars()
21
+
22
+ tasks = self.load_tasks()
23
+ self.execute_config_tasks(tasks)
28
24
  end
29
25
 
30
26
  def build()
31
27
  self.info("Building application.")
28
+
32
29
  Dir.chdir("#{self.build_dir()}/src") { `sh #{self.build_dir()}/src/build.sh` }
33
30
  end
34
31
 
@@ -49,197 +46,33 @@ module UcbDeployer
49
46
  end
50
47
 
51
48
 
49
+ protected
52
50
 
53
- def cas_logout_url()
54
- "/casLogout.action"
55
- end
51
+ def load_tasks()
52
+ # TODO: Automatically load tasks so we don't have to manually specify each one
53
+ #
54
+ #tasks_path = "#{File.expand_path(File.dirname(__FILE__))}/config_tasks/jira/"
55
+ #Dir.entries(tasks_path).select { |file| file.match(/^[a-z]/) }
56
+ #tasks.each do |task|
57
+ # klass_name = self.file_name_to_class_name(task)
58
+ # klass = ::Kernel.const_get("UcbDeployer::ConfigTasks::Jira::#{klass_name}")
59
+ # klass.new(self).execute()
60
+ #end
56
61
 
57
- ##
58
- # Shortcut to jira web.xml file
59
- #
60
- def web_xml()
61
- "#{self.build_dir()}/src/webapp/WEB-INF/web.xml"
62
- end
63
-
64
- def web_xml_token()
65
- "<!--This filter is used to determine is there are any Application Errors before any pages are accessed"
66
- end
67
-
68
- ##
69
- # Updates the jira web.xml file with the soulwing (CAS library)
70
- # authentication configuration
71
- #
72
- def config_web_xml()
73
- web_xml = File.readlines(self.web_xml()).map do |line|
74
- if line =~ /#{web_xml_token}/
75
- template = File.open("#{DEPLOYER_HOME}/resources/jira_cas_web.xml") { |f| f.read() }
76
- line + ERB.new(template).result(self.send(:binding))
77
- else
78
- line
79
- end
80
- end
81
-
82
- File.open(self.web_xml(), "w") do |io|
83
- web_xml.each { |line| io.puts(line) }
84
- end
85
- end
86
-
87
- ##
88
- # Shortcut to jira entityengine.xml file
89
- #
90
- def entityengine_xml()
91
- "#{self.build_dir()}/src/edit-webapp/WEB-INF/classes/entityengine.xml"
92
- end
93
-
94
- def entityengine_xml_db_token()
95
- "field-type-name=\"hsql\""
96
- end
97
-
98
- def entityengine_xml_schema_token()
99
- "schema-name=\"PUBLIC\""
100
- end
101
-
102
- def entityengine_db()
103
- "field-type-name=\"postgres72\""
104
- end
105
-
106
- def entityengine_schema()
107
- "schema-name=\"jira_app\""
108
- end
109
-
110
- ##
111
- # Updates the jira entityengine.xml file with the correct database configs
112
- #
113
- def config_entityengine_xml()
114
- ee_xml = File.readlines(self.entityengine_xml()).map do |line|
115
- if m = /(#{Regexp.quote(self.entityengine_xml_db_token())})/.match(line)
116
- self.debug(m[0])
117
- new_str = "#{m.pre_match}#{entityengine_db}#{m.post_match}"
118
- self.debug(new_str)
119
- new_str
120
- elsif m = /(#{Regexp.quote(self.entityengine_xml_schema_token())})/.match(line)
121
- self.debug(m[0])
122
- new_str = "#{m.pre_match}#{self.entityengine_schema()}#{m.post_match}"
123
- self.debug(new_str)
124
- new_str
125
- else
126
- line
127
- end
128
- end
129
-
130
- File.open(self.entityengine_xml(), "w") do |io|
131
- ee_xml.each { |line| io.puts(line) }
132
- end
133
- end
134
-
135
- ##
136
- # Shortcut to jira seraph-config.xml file
137
- #
138
- def seraph_config_xml()
139
- "#{self.build_dir()}/src/webapp/WEB-INF/classes/seraph-config.xml"
140
- end
141
-
142
- def seraph_config_xml_auth_class_token()
143
- "com.atlassian.jira.security.login.JiraSeraphAuthenticator"
144
- # "com.atlassian.jira.security.login.JiraOsUserAuthenticator"
145
- end
146
-
147
- def seraph_config_xml_logout_url_token()
148
- "/secure/Logout!default.jspa"
149
- end
150
-
151
- def cas_authenticator_class()
152
- "org.soulwing.cas.apps.atlassian.JiraCasAuthenticator"
153
- end
154
-
155
- ##
156
- # Updates the jira seraph_config.xml file with the soulwing
157
- # authenticator.
158
- #
159
- def config_seraph_config_xml()
160
- seraph_xml = File.readlines(self.seraph_config_xml()).map do |line|
161
- if m = /(#{Regexp.quote(self.seraph_config_xml_auth_class_token())})/.match(line)
162
- self.debug(m[0])
163
- new_str = "#{m.pre_match}#{self.cas_authenticator_class()}#{m.post_match}"
164
- self.debug(new_str)
165
- new_str
166
- elsif m = /(#{Regexp.quote(self.seraph_config_xml_logout_url_token())})/.match(line)
167
- self.debug(m[0])
168
- new_str = "#{m.pre_match}#{self.cas_server_url()}/logout#{m.post_match}"
169
- self.debug(new_str)
170
- new_str
171
- else
172
- line
173
- end
174
- end
175
-
176
- File.open(self.seraph_config_xml(), "w") do |io|
177
- seraph_xml.each { |line| io.puts(line) }
178
- end
179
- end
180
-
181
- ##
182
- # Shortcut to jira-application.properties file
183
- #
184
- def jira_application_properties()
185
- "#{self.build_dir()}/src/edit-webapp/WEB-INF/classes/jira-application.properties"
186
- end
187
-
188
- def jira_home_token()
189
- "jira.home ="
62
+ [ UcbDeployer::ConfigTasks::Jira::ConfigIstBanner.new(self),
63
+ UcbDeployer::ConfigTasks::Jira::ConfigCasAuth.new(self),
64
+ UcbDeployer::ConfigTasks::Jira::ConfigJiraConfigProperties.new(self),
65
+ UcbDeployer::ConfigTasks::Jira::ConfigAppProperties.new(self),
66
+ UcbDeployer::ConfigTasks::Jira::RemoveConflictingJarFiles.new(self), ]
190
67
  end
191
68
 
192
- def jira_projectkey_token()
193
- "jira.projectkey.pattern ="
194
- end
195
-
196
- ##
197
- # Sets the jira.home property in the file: jira-application.properties.
198
- #
199
- def config_jira_application_properties()
200
- jira_props = File.readlines(self.jira_application_properties()).map do |line|
201
- if m = /(#{Regexp.quote(jira_home_token)})/.match(line)
202
- self.debug(m[0])
203
- new_str = "#{self.jira_home_token()} #{self.data_dir()}"
204
- self.debug(new_str)
205
- new_str
206
- elsif m = /(#{Regexp.quote(jira_projectkey_token)})/.match(line)
207
- self.debug(m[0])
208
- new_str = "#{self.jira_projectkey_token()} ([A-Z][A-Z0-9]+)"
209
- self.debug(new_str)
210
- new_str
211
- else
212
- line
213
- end
214
- end
215
-
216
- File.open(self.jira_application_properties(), "w") do |io|
217
- jira_props.each { |line| io.puts(line) }
218
- end
69
+ def file_name_to_class_name(filename)
70
+ filename.gsub(/\.rb/, "").split("_").map(&:capitalize).join()
219
71
  end
220
72
 
221
- ##
222
- # Places IST banner jpg in imaages directory
223
- #
224
- def config_ist_banner()
225
- FileUtils.cp("#{UcbDeployer::RESOURCES_DIR}/ist_banner.jpg",
226
- "#{self.build_dir()}/src/webapp/images/")
227
- end
228
-
229
- ##
230
- # Remove jars from WEB-INF/lib that have been installed at the container
231
- # level to avoid conflicts.
232
- #
233
- def reshuffle_jars()
234
- FileUtils.mkdir_p("#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/")
235
- FileUtils.cp(Dir["#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*"],
236
- "#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/")
237
- # These have been placed in $CATALINA_HOME/lib
238
- ["mail", "activation", "javamail", "commons-logging", "log4j"].each do |jar_file|
239
- FileUtils.rm_rf(Dir["#{self.build_dir()}/src/webapp/WEB-INF/lib/#{jar_file}-*"])
240
- end
73
+ def execute_config_tasks(tasks)
74
+ tasks.each { |task| task.execute() }
241
75
  end
242
-
243
76
  end
244
77
  end
245
78
 
@@ -1,3 +1,3 @@
1
1
  module UcbDeployer
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/ucb_deployer.rb CHANGED
@@ -5,6 +5,12 @@ require 'ucb_deployer/deployer'
5
5
  require 'ucb_deployer/confluence_deployer'
6
6
  require 'ucb_deployer/jira_deployer'
7
7
 
8
+ require 'ucb_deployer/config_tasks/jira/config_cas_auth'
9
+ require 'ucb_deployer/config_tasks/jira/config_app_properties'
10
+ require 'ucb_deployer/config_tasks/jira/config_jira_config_properties'
11
+ require 'ucb_deployer/config_tasks/jira/config_ist_banner'
12
+ require 'ucb_deployer/config_tasks/jira/remove_conflicting_jar_files'
13
+
8
14
 
9
15
  module UcbDeployer
10
16
  class ConfigError < RuntimeError; end
@@ -44,7 +50,7 @@ module UcbDeployer
44
50
  $stdout.puts(str)
45
51
  end
46
52
 
47
- def self.debug_mode
53
+ def self.debug_mode()
48
54
  @debug_mode || false
49
55
  end
50
56
 
@@ -1,5 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8" ?>
2
- <!DOCTYPE entity-config PUBLIC "-//OFBiz//DTD Entity Engine Config//EN" "http://www.ofbiz.org/dtds/entity-config.dtd">
3
2
  <!--
4
3
  This file configures the OFBiz Entity Engine which JIRA uses to store persist data in a datasource.
5
4
 
@@ -71,44 +70,13 @@ If you not using the 12 preconfigured DBs, you may also need to add your own fie
71
70
  <field name="position" type="integer"/> to <field name="position" col-name="POSITION_" type="integer"/>
72
71
  -->
73
72
  <field-type name="frontbase" loader="maincp" location="entitydefs/fieldtype-frontbase.xml"/>
73
+ <!--
74
74
 
75
+ DATASOURCE
75
76
 
76
- <!-- DATASOURCE - You will need to update this tag for your installation.
77
-
78
- 1. Update field-type-name attribute to match your database.
79
- Possible values include: cloudscape, db2, firebird, frontbase, hsql, mckoidb, mysql, mssql, oracle10g, oracle, postgres, postgres72, sapdb, sybase
80
- 2. If using Orion or JBoss you will need to customize the <jndi-jdbc> tag.
81
- See http://www.atlassian.com/software/jira/docs/latest/servers/
82
- 3. If using Postgres 7.3+ (schema-aware), use:
83
- field-type-name="postgres72"
84
- and:
85
- schema-name="public"
86
- in the datasource attribute list below.
87
- 4. If using DB2, add:
88
- constraint-name-clip-length="15"
89
- to the datasource attribute list below, and an appropriate schema-name attribute, eg:
90
- schema-name="DB2INST1"
91
- 5. If not using HSQLDB remove:
92
- schema-name="PUBLIC"
93
-
94
- PLEASE DO NOT CHANGE the datasource name from
95
- defaultDS unless instructed to by Atlassian Support.
96
-
97
- PLEASE DO NOT set the use-foreign-key* values to "true" as JIRA does not currently support this.
77
+ You should no longer define a datasource in this file, the database is now configured through the UI at setup time.
78
+ The only time you would want to configure it here is when you migrate from an older version and need to point the
79
+ new installation at an existing db. This is considered a legacy method and will not work if dbconfig.xml exists
80
+ in the home directory.
98
81
  -->
99
- <datasource name="defaultDS" field-type-name="hsql"
100
- schema-name="PUBLIC"
101
- helper-class="org.ofbiz.core.entity.GenericHelperDAO"
102
- check-on-start="true"
103
- use-foreign-keys="false"
104
- use-foreign-key-indices="false"
105
- check-fks-on-start="false"
106
- check-fk-indices-on-start="false"
107
- add-missing-on-start="true"
108
- check-indices-on-start="true">
109
- <jndi-jdbc jndi-server-name="default" jndi-name="java:comp/env/jdbc/JiraDS"/>
110
- <!-- Orion format: <jndi-jdbc jndi-server-name="default" jndi-name="jdbc/JiraDS"/> -->
111
- <!-- JBoss format: <jndi-jdbc jndi-server-name="default" jndi-name="java:/DefaultDS"/> -->
112
- <!-- Weblogic format: <jndi-jdbc jndi-server-name="default" jndi-name="JiraDS"/> -->
113
- </datasource>
114
82
  </entity-config>