-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
388 lines (375 loc) · 28.8 KB
/
Rakefile
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
require 'rake'
require 'pry'
require 'rexml/document'
require 'gmail'
require 'zip'
include REXML
# Usage Sample,
# rake email["http://jenkins.io:8080/job/Automation/133","https://github.com/nareshnavinash/graber-ruby","master","SHA Key","commiter_email@testmail.com","nareshnavinash@gmail.com;naresh@testmail.com"]
task :email, :jenkins_url, :git_url, :git_branch, :git_commit, :git_commiter_email, :to_email do |t, args|
args.with_defaults(:jenkins_url => "http://jenkins.io:8080/job/Automation/", :git_branch => "master", :to_email => "nareshnavinash@gmail.com")
args.with_defaults(:git_url => "https://github.com/nareshnavinash/graber-ruby", :git_commit => "SHA Key", :git_commiter_email => "commiter_email@gmail.com")
puts args[:jenkins_url]
puts args[:git_commit]
puts args[:to_email]
passed_count = 0
failed_count = 0
break_count = 0
failed_testcases = []
break_testcases = []
Dir["reports/allure/*.xml"].each do |f|
xmlfile = File.new("#{f}")
xmldoc = Document.new(xmlfile)
XPath.each(xmldoc, "ns2:test-suite/test-cases/test-case").each do |e|
if e.attributes["status"] == "passed"
passed_count = passed_count + 1
elsif e.attributes["status"] == "failed"
failed_count = failed_count + 1
failed_testcases << XPath.first(e,"name").text
else
break_count = break_count + 1
break_testcases << XPath.first(e,"name").text
end
end
end
puts "Failed - "
puts failed_testcases
puts "Break - \n"
puts break_testcases
puts passed_count, failed_count, break_count
#Zipping the reporting folders
File.delete("#{Pathname.pwd}/reports/html.zip") if File.exist?("#{Pathname.pwd}/reports/html.zip")
File.delete("#{Pathname.pwd}/reports/pretty.zip") if File.exist?("#{Pathname.pwd}/reports/pretty.zip")
directory = "#{Pathname.pwd}/reports/pretty/"
zipfile_name = "#{Pathname.pwd}/reports/pretty.zip"
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
Dir[File.join(directory, '*')].each do |file|
zipfile.add(file.sub(directory, ''), file)
end
end
directory = "#{Pathname.pwd}/reports/html/"
zipfile_name = "#{Pathname.pwd}/reports/html.zip"
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
Dir[File.join(directory, '*')].each do |file|
zipfile.add(file.sub(directory, ''), file)
end
end
#Email parameters
email = "custom_email@gmail.com" #to send the email from this account
password = "Test@123"
to_email = args[:to_email] || "nareshnavinash@gmail.com"
if failed_count == 0 and break_count == 0
email_subject = "Automation - Report #{Time.now}"
else
email_subject = "Automation - Report #{Time.now} - Alert failure(s) found !!!"
end
if failed_testcases.count != 0
final_string = ""
failed_testcases.each do |f|
final_string = final_string + "<li>#{f}</li>"
end
failed_testcases_string = "
Failed Test Cases,
<ul>
#{final_string}
</ul>"
else
failed_testcases_string = ""
end
if break_testcases.count != 0
final_string = ""
break_testcases.each do |f|
final_string = final_string + "<li>#{f}</li>"
end
break_testcases_string = "
Broken Test Cases,
<ul>
#{final_string}
</ul>"
else
break_testcases_string = ""
end
email_values = {
"To" => "#{to_email}",
"Subject" => "#{email_subject}",
"Cc" => "",
"Body" => "
<body style=\"margin: 0; padding: 0;\">
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"background: #f3f3f3; min-width: 350px; font-size: 1px; line-height: normal;\">
<tr>
<td align=\"center\" valign=\"top\">
<!--[if (gte mso 9)|(IE)]>
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td align=\"center\" valign=\"top\" width=\"750\"><![endif]-->
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"750\" class=\"table750\" style=\"width: 100%; max-width: 750px; min-width: 350px; background: #f3f3f3;\">
<tr>
<td class=\"mob_pad\" width=\"25\" style=\"width: 25px; max-width: 25px; min-width: 25px;\"> </td>
<td align=\"center\" valign=\"top\" style=\"background: #ffffff;\">
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"width: 100% !important; min-width: 100%; max-width: 100%; background: #f3f3f3;\">
<tr>
<td align=\"right\" valign=\"top\">
<div class=\"top_pad\" style=\"height: 25px; line-height: 25px; font-size: 23px;\"> </div>
</td>
</tr>
</table>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"width: 100% !important; min-width: 100%; max-width: 100%; background: #f3f3f3;\">
<tr>
<td align=\"right\" valign=\"top\">
<div class=\"top_pad\" style=\"height: 25px; line-height: 25px; font-size: 23px;\"> </div>
</td>
</tr>
</table>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"88%\" style=\"width: 88% !important; min-width: 88%; max-width: 88%;\">
<tr>
<td align=\"left\" valign=\"top\">
<div style=\"height: 10px; line-height: 33px; font-size: 31px;\"> </div>
<div class=\"header\" align=\"center\">
<h2 style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #3375AA; font-size: 32px; line-height: 32px;\">Automation Report</h2>
</div>
<div style=\"height: 10px; line-height: 33px; font-size: 31px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#1a1a1a\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 20px; line-height: 32px;\">Hi Team,</span>
</font>
<div style=\"height: 33px; line-height: 33px; font-size: 31px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 20px; line-height: 32px;\">GraphQL Automation Regression Status,</span>
</font>
<div style=\"height: 20px; line-height: 20px; font-size: 20px;\"> </div>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"88%\" style=\"width: 88% !important; min-width: 88%; max-width: 88%;\">
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 18px; line-height: 32px;\">Passed Test Case count :</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #0E9C4A; font-size: 18px; line-height: 32px;\">#{passed_count}</span>
</font>
</td>
</tr>
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 18px; line-height: 32px;\">Failed Test Case count :</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #B2230F; font-size: 18px; line-height: 32px;\">#{failed_count}</span>
</font>
</td>
</tr>
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 18px; line-height: 32px;\">Broken Test Case count :</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #E6C404; font-size: 18px; line-height: 32px;\">#{break_count}</span>
</font>
</td>
</tr>
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 18px; line-height: 32px;\">Run Completed at :</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #130145; font-size: 18px; line-height: 32px;\">#{Time.now}</span>
</font>
</td>
</tr>
</table>
<div style=\"height: 33px; line-height: 33px; font-size: 31px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 18px; line-height: 32px;\">HTML Reports and Command line logs are attached for reference. Below are the few parameters that are responsible for this job trigger. If any failures or broken cases found in the result kindly trace back from the last commit ID with the last commited user.</span>
</font>
<div style=\"height: 20px; line-height: 20px; font-size: 31px;\"> </div>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"88%\" style=\"width: 88% !important; min-width: 88%; max-width: 88%;\">
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 17px; line-height: 32px;\">Jenkins URL:</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<a href=\"#{args[:jenkins_url]}\" style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #130145; font-size: 17px; line-height: 32px;\">navigate_to_jenkins</a>
</font>
</td>
</tr>
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 17px; line-height: 32px;\">Git Branch:</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #130145; font-size: 17px; line-height: 32px;\">#{args[:git_branch]}</span>
</font>
</td>
</tr>
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 17px; line-height: 32px;\">Last Commit ID:</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #130145; font-size: 17px; line-height: 32px;\">#{args[:git_commit]}</span>
</font>
</td>
</tr>
<tr>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 17px; line-height: 32px;\">Last Commit by:</span>
</font>
</td>
<td align=\"left\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #130145; font-size: 17px; line-height: 32px;\">#{args[:git_commiter_email]}</span>
</font>
</td>
</tr>
</table>
<div style=\"height: 33px; line-height: 33px; font-size: 31px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 18px; line-height: 32px;\">Follow the following Link for detailed analysis in allure,</span>
</font>
<div style=\"height: 10px; line-height: 10px; font-size: 10px;\"> </div>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"88%\" style=\"width: 88% !important; min-width: 88%; max-width: 88%;\">
<tr>
<td align=\"left\" valign=\"top\">
<table class=\"mob_btn\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background: #27cbcc; border-radius: 4px;\">
<tr>
<td align=\"center\" valign=\"top\">
<a href=\"#{args[:jenkins_url]}allure/\" target=\"_blank\" style=\"display: block; border: 1px solid #27cbcc; border-radius: 4px; padding: 4px 8px; font-family: 'Source Sans Pro', Arial, Verdana, Tahoma, Geneva, sans-serif; color: #ffffff; font-size: 20px; line-height: 30px; text-decoration: none; white-space: nowrap; font-weight: 600;\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#ffffff\" style=\"font-size: 20px; line-height: 30px; text-decoration: none; white-space: nowrap; font-weight: 600;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Verdana, Tahoma, Geneva, sans-serif; color: #ffffff; font-size: 20px; line-height: 30px; text-decoration: none; white-space: nowrap; font-weight: 600;\">Allure Report</span>
</font>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div style=\"height: 45px; line-height: 10px; font-size: 10px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 16px; line-height: 32px;\">This email is auto-triggered from Jenkins Automation Job, for any queries please contact </span>
<a href=\"mailto:nareshnavinash@gmail.com\" style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 16px; line-height: 32px;\"> nareshnavinash@gmail.com</a>
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 16px; line-height: 32px;\"> or </span>
<a href=\"mailto:nareshsekar@zoho.com\" style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 16px; line-height: 32px;\">nareshsekar@zoho.com.</a>
</font>
<div style=\"height: 33px; line-height: 33px; font-size: 31px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 16px; line-height: 32px;\">#{failed_testcases_string}</span>
</font>
<div style=\"height: 1px; line-height: 1px; font-size: 31px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#585858\" style=\"font-size: 24px; line-height: 32px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #585858; font-size: 16px; line-height: 32px;\">#{break_testcases_string}</span>
</font>
<div style=\"height: 33px; line-height: 33px; font-size: 31px;\"> </div>
</td>
</tr>
</table>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"90%\" style=\"width: 90% !important; min-width: 90%; max-width: 90%; border-width: 1px; border-style: solid; border-color: #e8e8e8; border-bottom: none; border-left: none; border-right: none;\">
<tr>
<td align=\"left\" valign=\"top\">
<div style=\"height: 15px; line-height: 15px; font-size: 13px;\"> </div>
</td>
</tr>
</table>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"88%\" style=\"width: 88% !important; min-width: 88%; max-width: 88%;\">
<tr>
<td class=\"mob_center\" align=\"left\" valign=\"top\">
<div style=\"height: 10px; line-height: 10px; font-size: 11px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#000000\" style=\"font-size: 19px; line-height: 23px; font-weight: 600;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #7f7f7f; font-size: 19px; line-height: 23px;\">Thanks,</span>
</font>
<div style=\"height: 1px; line-height: 1px; font-size: 1px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#7f7f7f\" style=\"font-size: 19px; line-height: 23px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #000000; font-size: 19px; line-height: 23px; font-weight: 600;\">SDET Team.</span>
</font>
<div style=\"height: 25px; line-height: 20px; font-size: 15px;\"> </div>
</td>
</tr>
</table>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"width: 100% !important; min-width: 100%; max-width: 100%; background: #f3f3f3;\">
<tr>
<td align=\"center\" valign=\"top\">
<div style=\"height: 34px; line-height: 34px; font-size: 32px;\"> </div>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"88%\" style=\"width: 88% !important; min-width: 88%; max-width: 88%;\">
<tr>
<td align=\"center\" valign=\"top\">
<font face=\"'Source Sans Pro', sans-serif\" color=\"#868686\" style=\"font-size: 17px; line-height: 20px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #868686; font-size: 17px; line-height: 20px;\">Copyright © 2020 Naresh Sekar. All Rights Reserved. Confidential attachments!</span>
</font>
<div style=\"height: 2px; line-height: 2px; font-size: 32px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#868686\" style=\"font-size: 17px; line-height: 20px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #868686; font-size: 17px; line-height: 20px;\">Beware Before Forwarding this e-mail!</span>
</font>
<div style=\"height: 3px; line-height: 3px; font-size: 1px;\"> </div>
<font face=\"'Source Sans Pro', sans-serif\" color=\"#1a1a1a\" style=\"font-size: 17px; line-height: 20px;\">
<span style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #1a1a1a; font-size: 17px; line-height: 20px;\"><a href=\"mailto:nareshnavinash@gmail.com\" target=\"_blank\" style=\"font-family: 'Source Sans Pro', Arial, Tahoma, Geneva, sans-serif; color: #1a1a1a; font-size: 17px; line-height: 20px; text-decoration: none;\">nareshnavinash@gmail.com</a>
</font>
<div style=\"height: 35px; line-height: 35px; font-size: 33px;\"> </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td class=\"mob_pad\" width=\"25\" style=\"width: 25px; max-width: 25px; min-width: 25px;\"> </td>
</tr>
</table>
<!--[if (gte mso 9)|(IE)]>
</td></tr>
</table><![endif]-->
</td>
</tr>
</table>
</body>
",
"Body Type" => "html",
"Attachments" => "reports/html/*.html"
}
puts "Send email to below values #{email_values.to_s}"
@current_instance = Gmail.new(email,password)
@current_instance.deliver do
to email_values["To"] if email_values["To"] != nil
cc email_values["Cc"] if email_values["Cc"] != nil
bcc email_values["Bcc"] if email_values["Bcc"] != nil
subject email_values["Subject"] if email_values["Subject"] != nil
if email_values["Body Type"] == "text" && email_values["Body Type"] != nil
text_part do
body email_values["Body"]
end
elsif email_values["Body Type"] == "html" && email_values["Body Type"] != nil
html_part do
content_type 'text/html; charset=UTF-8'
body email_values["Body"]
end
else
body email_values["Body"] if email_values["Body"] != nil
end
if email_values["Attachments"] != nil
attachments_values = Dir["reports/*.zip"]
attachments_values.each do |attachment_value|
file_path = "#{Pathname.pwd}/#{attachment_value}"
add_file file_path
end
end
end
puts "Logout the gmail instance"
@current_instance.logout
end