1
1
'use strict' ;
2
2
const path = require ( 'path' ) ;
3
+ const { inspect } = require ( 'util' ) ;
3
4
4
5
const archiver = require ( "../helpers/archiver" ) ,
5
6
zipUploader = require ( "../helpers/zipUpload" ) ,
@@ -11,6 +12,7 @@ const archiver = require("../helpers/archiver"),
11
12
utils = require ( "../helpers/utils" ) ,
12
13
fileHelpers = require ( "../helpers/fileHelpers" ) ,
13
14
syncRunner = require ( "../helpers/syncRunner" ) ,
15
+ getInitialDetails = require ( "../helpers/getInitialDetails" ) . getInitialDetails ,
14
16
checkUploaded = require ( "../helpers/checkUploaded" ) ,
15
17
packageInstaller = require ( "../helpers/packageInstaller" ) ,
16
18
reportGenerator = require ( '../helpers/reporterHTML' ) . reportGenerator ,
@@ -44,6 +46,13 @@ module.exports = function run(args, rawArgs) {
44
46
// accept the access key from command line or env variable if provided
45
47
utils . setAccessKey ( bsConfig , args ) ;
46
48
49
+ let initDetails = await getInitialDetails ( bsConfig , args , rawArgs ) ;
50
+
51
+ let buildReportData = {
52
+ 'user_id' : initDetails . user_id
53
+ } ;
54
+
55
+ console . log ( `roshan1: bhai the initDetails are the ${ inspect ( buildReportData ) } ` )
47
56
// accept the build name from command line if provided
48
57
utils . setBuildName ( bsConfig , args ) ;
49
58
@@ -113,7 +122,7 @@ module.exports = function run(args, rawArgs) {
113
122
utils . setParallels ( bsConfig , args , specFiles . length ) ;
114
123
115
124
// warn if specFiles cross our limit
116
- utils . warnSpecLimit ( bsConfig , args , specFiles , rawArgs ) ;
125
+ utils . warnSpecLimit ( bsConfig , args , specFiles , rawArgs , buildReportData ) ;
117
126
markBlockEnd ( 'preArchiveSteps' ) ;
118
127
markBlockStart ( 'zip' ) ;
119
128
markBlockStart ( 'zip.checkAlreadyUploaded' ) ;
@@ -141,20 +150,16 @@ module.exports = function run(args, rawArgs) {
141
150
// Create build
142
151
//setup Local Testing
143
152
markBlockStart ( 'localSetup' ) ;
144
- let bs_local = await utils . setupLocalTesting ( bsConfig , args , rawArgs ) ;
153
+ let bs_local = await utils . setupLocalTesting ( bsConfig , args , rawArgs , buildReportData ) ;
145
154
markBlockEnd ( 'localSetup' ) ;
146
155
markBlockStart ( 'createBuild' ) ;
147
156
return build . createBuild ( bsConfig , zip ) . then ( function ( data ) {
148
157
markBlockEnd ( 'createBuild' ) ;
149
158
markBlockEnd ( 'total' ) ;
150
- utils . setProcessHooks ( data . build_id , bsConfig , bs_local , args ) ;
159
+ utils . setProcessHooks ( data . build_id , bsConfig , bs_local , args , buildReportData ) ;
151
160
let message = `${ data . message } ! ${ Constants . userMessages . BUILD_CREATED } with build id: ${ data . build_id } ` ;
152
161
let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ data . dashboard_url } ` ;
153
- let buildReportData = {
154
- 'build_id' : data . build_id ,
155
- 'user_id' : data . user_id ,
156
- 'parallels' : userSpecifiedParallels
157
- } ;
162
+ buildReportData = { 'build_id' : data . build_id , 'user_id' : data . user_id , ...buildReportData }
158
163
utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
159
164
if ( ( utils . isUndefined ( bsConfig . run_settings . parallels ) && utils . isUndefined ( args . parallels ) ) || ( ! utils . isUndefined ( bsConfig . run_settings . parallels ) && bsConfig . run_settings . parallels == Constants . cliMessages . RUN . DEFAULT_PARALLEL_MESSAGE ) ) {
160
165
logger . warn ( Constants . userMessages . NO_PARALLELS ) ;
@@ -177,22 +182,22 @@ module.exports = function run(args, rawArgs) {
177
182
178
183
179
184
if ( args . sync ) {
180
- syncRunner . pollBuildStatus ( bsConfig , data , rawArgs ) . then ( async ( exitCode ) => {
185
+ syncRunner . pollBuildStatus ( bsConfig , data , rawArgs , buildReportData ) . then ( async ( exitCode ) => {
181
186
182
187
// stop the Local instance
183
- await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs ) ;
188
+ await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs , buildReportData ) ;
184
189
185
190
// waiting for 5 secs for upload to complete (as a safety measure)
186
191
await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
187
192
188
193
// download build artifacts
189
194
if ( exitCode != Constants . BUILD_FAILED_EXIT_CODE ) {
190
195
if ( utils . nonEmptyArray ( bsConfig . run_settings . downloads ) ) {
191
- await downloadBuildArtifacts ( bsConfig , data . build_id , args , rawArgs ) ;
196
+ await downloadBuildArtifacts ( bsConfig , data . build_id , args , rawArgs , buildReportData ) ;
192
197
}
193
198
194
199
// Generate custom report!
195
- reportGenerator ( bsConfig , data . build_id , args , rawArgs , function ( ) {
200
+ reportGenerator ( bsConfig , data . build_id , args , rawArgs , buildReportData , function ( ) {
196
201
utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null , buildReportData , rawArgs ) ;
197
202
utils . handleSyncExit ( exitCode , data . dashboard_url ) ;
198
203
} ) ;
@@ -268,22 +273,22 @@ module.exports = function run(args, rawArgs) {
268
273
// stop the Local instance
269
274
await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs ) ;
270
275
271
- utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' , null , rawArgs ) ;
276
+ utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' , buildReportData , rawArgs ) ;
272
277
process . exitCode = Constants . ERROR_EXIT_CODE ;
273
278
} ) ;
274
279
} ) . catch ( function ( err ) {
275
280
// Zip Upload failed | Local Start failed
276
281
logger . error ( err ) ;
277
282
if ( err === Constants . userMessages . LOCAL_START_FAILED ) {
278
- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' , null , rawArgs ) ;
283
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' , buildReportData , rawArgs ) ;
279
284
} else {
280
285
logger . error ( Constants . userMessages . ZIP_UPLOAD_FAILED ) ;
281
286
fileHelpers . deleteZip ( ) ;
282
- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' , null , rawArgs ) ;
287
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' , buildReportData , rawArgs ) ;
283
288
try {
284
289
fileHelpers . deletePackageArchieve ( ) ;
285
290
} catch ( err ) {
286
- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
291
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
287
292
}
288
293
}
289
294
process . exitCode = Constants . ERROR_EXIT_CODE ;
@@ -292,36 +297,36 @@ module.exports = function run(args, rawArgs) {
292
297
// Zipping failed
293
298
logger . error ( err ) ;
294
299
logger . error ( Constants . userMessages . FAILED_TO_ZIP ) ;
295
- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' , null , rawArgs ) ;
300
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' , buildReportData , rawArgs ) ;
296
301
try {
297
302
fileHelpers . deleteZip ( ) ;
298
303
} catch ( err ) {
299
- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' , null , rawArgs ) ;
304
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' , buildReportData , rawArgs ) ;
300
305
}
301
306
try {
302
307
fileHelpers . deletePackageArchieve ( ) ;
303
308
} catch ( err ) {
304
- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
309
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
305
310
}
306
311
process . exitCode = Constants . ERROR_EXIT_CODE ;
307
312
} ) ;
308
313
} ) . catch ( function ( err ) {
309
314
// package installer failed
310
315
logger . error ( err ) ;
311
316
logger . error ( Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE ) ;
312
- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE , Constants . messageTypes . ERROR , 'npm_package_archive_failed' , null , rawArgs ) ;
317
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE , Constants . messageTypes . ERROR , 'npm_package_archive_failed' , buildReportData , rawArgs ) ;
313
318
try {
314
319
fileHelpers . deletePackageArchieve ( ) ;
315
320
} catch ( err ) {
316
- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
321
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
317
322
}
318
323
process . exitCode = Constants . ERROR_EXIT_CODE ;
319
324
} ) ;
320
325
} ) . catch ( function ( err ) {
321
326
// md5 check failed
322
327
logger . error ( err ) ;
323
328
logger . error ( Constants . userMessages . FAILED_MD5_CHECK ) ;
324
- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . MD5_CHECK_FAILED , Constants . messageTypes . ERROR , 'zip_already_uploaded_failed' , null , rawArgs ) ;
329
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . MD5_CHECK_FAILED , Constants . messageTypes . ERROR , 'zip_already_uploaded_failed' , buildReportData , rawArgs ) ;
325
330
process . exitCode = Constants . ERROR_EXIT_CODE ;
326
331
} ) ;
327
332
} ) . catch ( function ( err ) {
@@ -335,7 +340,7 @@ module.exports = function run(args, rawArgs) {
335
340
}
336
341
337
342
let error_code = utils . getErrorCodeFromMsg ( err ) ;
338
- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . validationMessages . NOT_VALID } ` , Constants . messageTypes . ERROR , error_code , null , rawArgs ) ;
343
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . validationMessages . NOT_VALID } ` , Constants . messageTypes . ERROR , error_code , buildReportData , rawArgs ) ;
339
344
process . exitCode = Constants . ERROR_EXIT_CODE ;
340
345
} ) ;
341
346
} ) . catch ( function ( err ) {
0 commit comments