azdeploy 1.0.17 → 1.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/azdeploy.gemspec +2 -2
- data/lib/build.rb +29 -24
- data/lib/transform.rb +73 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8e16b3c1bc5ed7c3cfc80754240cb1b103e84fe
|
4
|
+
data.tar.gz: 5b155e7da4b288d32fb718e05cda47b45fc1aa1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e59d0597681743a899c8827aae9c6a65b2e34d1f14835b443449c91f5d9fde241349ac4f8288ac19392680636915bffd044a70f19d3348d236f4b1a95d814d3
|
7
|
+
data.tar.gz: 4151d85bb31c515ae1a11be5a50ab553509392144615a21a53050560a1e122069c88e10ad19f2ee429e18939328e0d13aee6aeca74cbefe802c04e63bee3670a
|
data/azdeploy.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'azdeploy'
|
3
|
-
s.version = '1.0.
|
4
|
-
s.date = '2015-
|
3
|
+
s.version = '1.0.18'
|
4
|
+
s.date = '2015-08-04'
|
5
5
|
s.summary = 'Setup and scripting support for .Net project builds'
|
6
6
|
s.description = 'Azure Deployment Gem. Provides easy setup and deployment scripting support for .Net project builds'
|
7
7
|
s.authors = ['Suresh Batta']
|
data/lib/build.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
$versionMap = {}
|
2
2
|
|
3
3
|
def copy_output_files(fromDir, filePattern, outDir)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
FileUtils.mkdir_p outDir unless exists?(outDir)
|
5
|
+
Dir.glob(File.join(fromDir, filePattern)){|file|
|
6
|
+
copy(file, outDir) if File.file?(file)
|
7
|
+
}
|
8
8
|
end
|
9
9
|
|
10
10
|
def project_outputs(props)
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
props[:projects].map{ |p| "src/#{p}/bin/#{BUILD_CONFIG}/#{p}.dll" }.
|
12
|
+
concat( props[:projects].map{ |p| "src/#{p}/bin/#{BUILD_CONFIG}/#{p}.exe" } ).
|
13
|
+
find_all{ |path| exists?(path) }
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_commit_hash_and_date
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
begin
|
18
|
+
commit = `git log -1 --pretty=format:%H`
|
19
|
+
git_date = `git log -1 --date=iso --pretty=format:%ad`
|
20
|
+
commit_date = DateTime.parse( git_date ).strftime("%Y-%m-%d %H%M%S")
|
21
|
+
rescue
|
22
|
+
commit = "git unavailable"
|
23
|
+
end
|
24
|
+
|
25
|
+
[commit, commit_date]
|
26
26
|
end
|
27
27
|
|
28
28
|
def add_files stage, what_dlls, nuspec, folder='lib'
|
@@ -48,14 +48,14 @@ def commit_data
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def waitfor(&block)
|
51
|
-
|
51
|
+
checks = 0
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
until block.call || checks >10
|
54
|
+
sleep 0.5
|
55
|
+
checks += 1
|
56
|
+
end
|
57
57
|
|
58
|
-
|
58
|
+
raise 'Waitfor timeout expired. Make sure that you aren\'t running something from the build output folders, or that you have browsed to it through Explorer.' if checks > 10
|
59
59
|
end
|
60
60
|
|
61
61
|
def cleantask(props)
|
@@ -78,6 +78,11 @@ def cleantask(props)
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def restore_nuget(nuget_exe)
|
82
|
+
sh 'powershell', '-Command', "& { Invoke-RestMethod https://www.nuget.org/nuget.exe -OutFile '#{nuget_exe}' }"
|
83
|
+
sh nuget_exe, 'restore', "src/#{PRODUCT}.sln"
|
84
|
+
end
|
85
|
+
|
81
86
|
def restore_project_pkgs(proj)
|
82
87
|
msbuild :nuget_restore do |msb|
|
83
88
|
msb.use :net4
|
@@ -88,8 +93,8 @@ end
|
|
88
93
|
|
89
94
|
def clean_build(msb, solution)
|
90
95
|
msb.properties :Configuration => 'Release',
|
91
|
-
|
92
|
-
|
96
|
+
:Platform => 'Any CPU',
|
97
|
+
:VisualStudioVersion => '12.0'
|
93
98
|
msb.use :net4
|
94
99
|
msb.solution = solution
|
95
100
|
end
|
data/lib/transform.rb
CHANGED
@@ -5,7 +5,12 @@ class Transform
|
|
5
5
|
attr_accessor :table
|
6
6
|
attr_accessor :settings
|
7
7
|
attr_accessor :config_files
|
8
|
-
|
8
|
+
|
9
|
+
NO = 'no'
|
10
|
+
ROWKEY = 'RowKey'
|
11
|
+
SETTING = 'setting'
|
12
|
+
VALUE = 'value'
|
13
|
+
|
9
14
|
def get(key)
|
10
15
|
begin
|
11
16
|
result = @svc.get_entity(@table, @env, key)
|
@@ -34,8 +39,8 @@ class Transform
|
|
34
39
|
def get_value(key)
|
35
40
|
value = ''
|
36
41
|
@settings.each { |i|
|
37
|
-
if i.properties[
|
38
|
-
value = i.properties[
|
42
|
+
if i.properties[ROWKEY] == key
|
43
|
+
value = i.properties[SETTING]
|
39
44
|
break
|
40
45
|
end
|
41
46
|
}
|
@@ -43,23 +48,35 @@ class Transform
|
|
43
48
|
value
|
44
49
|
end
|
45
50
|
|
51
|
+
def transform_connstring(connstr)
|
52
|
+
@config_files.each{|file|
|
53
|
+
doc = Nokogiri::XML(File.read(file))
|
54
|
+
puts "Processing file: #{file}"
|
55
|
+
node = doc.at_css "appSettings/add[@key='connectionString']"
|
56
|
+
if !node.nil?
|
57
|
+
node[VALUE] = connstr
|
58
|
+
File.write(file, doc.to_xml)
|
59
|
+
end
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
46
63
|
def transform_appsettings
|
47
64
|
# go to each file and replace value of matching appSettings key
|
48
65
|
@config_files.each{|file|
|
49
66
|
doc = Nokogiri::XML(File.read(file))
|
50
67
|
puts "Processing file: #{file}"
|
51
68
|
@settings.each { |i|
|
52
|
-
key = i.properties[
|
69
|
+
key = i.properties[ROWKEY]
|
53
70
|
node = doc.at_css "appSettings/add[@key='#{key}']"
|
54
71
|
if !node.nil?
|
55
|
-
oldVal = node[
|
72
|
+
oldVal = node[VALUE]
|
56
73
|
#puts "Old value: #{oldVal}"
|
57
|
-
node[
|
58
|
-
newVal = node[
|
74
|
+
node[VALUE] = i.properties[SETTING]
|
75
|
+
newVal = node[VALUE]
|
59
76
|
#puts "New value: #{newVal}"
|
77
|
+
File.write(file, doc.to_xml)
|
60
78
|
end
|
61
|
-
}
|
62
|
-
File.write(file, doc.to_xml)
|
79
|
+
}
|
63
80
|
}
|
64
81
|
end
|
65
82
|
|
@@ -68,13 +85,15 @@ class Transform
|
|
68
85
|
doc = Nokogiri::XML(File.read(file))
|
69
86
|
doc.xpath('//system.serviceModel').each do |node|
|
70
87
|
#puts node
|
71
|
-
if
|
72
|
-
|
73
|
-
|
74
|
-
|
88
|
+
if !node.nil?
|
89
|
+
if file.end_with?('app.config') || file.end_with?('App.config')
|
90
|
+
node.replace(get_value('system.ServiceModel.Client'))
|
91
|
+
elsif file.end_with?('Web.config')
|
92
|
+
node.replace(get_value('system.ServiceModel.Service'))
|
93
|
+
end
|
94
|
+
File.write(file, doc.to_xml)
|
75
95
|
end
|
76
96
|
end
|
77
|
-
File.write(file, doc.to_xml)
|
78
97
|
}
|
79
98
|
end
|
80
99
|
|
@@ -193,23 +212,53 @@ class Transform
|
|
193
212
|
end
|
194
213
|
|
195
214
|
def transform
|
196
|
-
|
215
|
+
|
216
|
+
# find all App.config and web.config files
|
217
|
+
@config_files = Dir.glob('**/app.config')
|
218
|
+
@config_files.concat(Dir.glob('**/appSettings.config'))
|
219
|
+
@config_files.concat(Dir.glob('**/web.config'))
|
220
|
+
|
221
|
+
settings_account_name = ENV['SettingsAccount'] || NO
|
222
|
+
if (settings_account_name == NO)
|
223
|
+
puts "No settings storage account name found"
|
224
|
+
return false
|
225
|
+
end
|
226
|
+
settings_access_key = ENV['SettingsAccountKey'] || NO
|
227
|
+
if (settings_access_key == NO)
|
228
|
+
puts "No settings storage account key found"
|
229
|
+
return false
|
230
|
+
end
|
231
|
+
config_table = ENV['ConfigSettingsTable'] || NO
|
232
|
+
if (config_table == NO)
|
233
|
+
puts "No configuration table found"
|
234
|
+
return false
|
235
|
+
end
|
236
|
+
|
237
|
+
puts 'updating settings connection string...'
|
238
|
+
settings_connstr = "DefaultEndpointsProtocol=https;AccountName=#{settings_account_name};AccountKey=#{settings_access_key}"
|
239
|
+
should_update_settings_connstr = ENV['should_update_settings_connstr'] || NO
|
240
|
+
if should_update_settings_connstr == NO
|
241
|
+
puts 'Flag for Setttings Connection String Update not set.'
|
242
|
+
else
|
243
|
+
transform_connstring(settings_connstr)
|
244
|
+
end
|
245
|
+
|
197
246
|
# environment invoked
|
198
|
-
@env = ENV['env'] ||
|
199
|
-
if @env ==
|
247
|
+
@env = ENV['env'] || NO
|
248
|
+
if @env == NO
|
200
249
|
puts 'Environment name required to transform. No configuration changes will be done...'
|
201
250
|
return false
|
202
251
|
end
|
203
|
-
|
204
|
-
is_service = ENV['ServiceName'] ||
|
205
|
-
puts 'Target to transform is not a service...' if is_service ==
|
252
|
+
|
253
|
+
is_service = ENV['ServiceName'] || NO
|
254
|
+
puts 'Target to transform is not a service...' if is_service == NO
|
206
255
|
|
207
256
|
puts "Transforming config for environment: #{@env} ..."
|
208
257
|
|
209
258
|
# azure table storage account where settings reside
|
210
|
-
Azure.config.storage_account_name =
|
211
|
-
Azure.config.storage_access_key =
|
212
|
-
@table =
|
259
|
+
Azure.config.storage_account_name = settings_account_name
|
260
|
+
Azure.config.storage_access_key = settings_access_key
|
261
|
+
@table = config_table
|
213
262
|
|
214
263
|
# table service
|
215
264
|
@svc = Azure::TableService.new
|
@@ -217,11 +266,6 @@ class Transform
|
|
217
266
|
# get all settings for environment
|
218
267
|
@settings = get_all
|
219
268
|
|
220
|
-
# find all App.config and web.config files
|
221
|
-
@config_files = Dir.glob('**/app.config')
|
222
|
-
@config_files.concat(Dir.glob('**/appSettings.config'))
|
223
|
-
@config_files.concat(Dir.glob('**/web.config'))
|
224
|
-
|
225
269
|
if is_service
|
226
270
|
|
227
271
|
puts 'Obtaining cloud configuration templates...'
|
@@ -246,7 +290,7 @@ class Transform
|
|
246
290
|
transform_servicemodelconfig
|
247
291
|
|
248
292
|
end
|
249
|
-
|
293
|
+
|
250
294
|
puts 'Replacing app settings...'
|
251
295
|
transform_appsettings
|
252
296
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azdeploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suresh Batta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Azure Deployment Gem. Provides easy setup and deployment scripting support
|
14
14
|
for .Net project builds
|