@@ -31,6 +31,7 @@ export class BundleDeployer {
31
31
private parmsValidated : boolean = false ;
32
32
private hlqsValidated : boolean = false ;
33
33
private jobId : string ;
34
+ private progressBar : ITaskWithStatus ;
34
35
35
36
/**
36
37
* Constructor for a BundleDeployer.
@@ -249,66 +250,66 @@ export class BundleDeployer {
249
250
this . hlqsValidated = true ;
250
251
}
251
252
252
- private updateProgressBar ( status : ITaskWithStatus , action : string ) {
253
+ private updateProgressBar ( action : string ) {
253
254
// Increment the progress by 1%. This will refresh what the user sees
254
255
// on the console.
255
- status . percentComplete = status . percentComplete + 1 ;
256
+ this . progressBar . percentComplete += 1 ;
256
257
257
258
// Have a look at the status message for the progress bar, has it been updated with
258
259
// the jobid yet? If so, parse it out and refresh the message.
259
260
if ( this . jobId === "UNKNOWN" ) {
260
- const statusWords = status . statusMessage . split ( " " ) ;
261
+ const statusWords = this . progressBar . statusMessage . split ( " " ) ;
261
262
if ( statusWords . length >= 2 ) {
262
263
if ( statusWords [ 2 ] !== undefined && statusWords [ 2 ] . indexOf ( "JOB" ) === 0 ) {
263
264
this . jobId = statusWords [ 2 ] ;
264
- status . statusMessage += " (Processing DFHDPLOY " + action + " action)" ;
265
+ this . progressBar . statusMessage += " (Processing DFHDPLOY " + action + " action)" ;
265
266
266
- this . params . response . progress . endBar ( ) ;
267
+ this . endProgressBar ( ) ;
267
268
// log the jobid for posterity
268
269
if ( this . params . arguments . verbose ) {
269
- this . params . response . console . log ( status . statusMessage + "\n" ) ;
270
+ this . params . response . console . log ( this . progressBar . statusMessage + "\n" ) ;
270
271
}
271
272
if ( this . params . arguments . silent === undefined ) {
272
273
const logger = Logger . getAppLogger ( ) ;
273
- logger . debug ( status . statusMessage ) ;
274
+ logger . debug ( this . progressBar . statusMessage ) ;
274
275
}
275
- this . params . response . progress . startBar ( { task : status } ) ;
276
+ this . startProgressBar ( ) ;
276
277
}
277
278
}
278
279
}
279
280
280
281
// Continue iterating on progress updates until we've reached the max value,
281
282
// or until the processing has completed.
282
- if ( status . percentComplete < this . PROGRESS_BAR_MAX &&
283
- status . stageName === TaskStage . IN_PROGRESS ) {
284
- setTimeout ( this . updateProgressBar . bind ( this ) , this . PROGRESS_BAR_INTERVAL , status , action ) ;
283
+ if ( this . progressBar . percentComplete < this . PROGRESS_BAR_MAX &&
284
+ this . progressBar . stageName === TaskStage . IN_PROGRESS ) {
285
+ setTimeout ( this . updateProgressBar . bind ( this ) , this . PROGRESS_BAR_INTERVAL , action ) ;
285
286
}
286
287
}
287
288
288
289
private async submitJCL ( jcl : string , action : string , session : any ) : Promise < string > {
289
290
let spoolOutput : any ;
290
- const status : ITaskWithStatus = { percentComplete : TaskProgress . TEN_PERCENT ,
291
- statusMessage : "Submitting DFHDPLOY JCL for the " + action + " action" ,
292
- stageName : TaskStage . IN_PROGRESS } ;
293
- this . params . response . progress . startBar ( { task : status } ) ;
291
+ this . progressBar = { percentComplete : TaskProgress . TEN_PERCENT ,
292
+ statusMessage : "Submitting DFHDPLOY JCL for the " + action + " action" ,
293
+ stageName : TaskStage . IN_PROGRESS } ;
294
+ this . startProgressBar ( ) ;
294
295
this . jobId = "UNKNOWN" ;
295
296
296
297
// Refresh the progress bar by 1% every second or so up to a max of 67%.
297
298
// SubmitJobs will initialise it to 30% and set it to 70% when it
298
299
// completes, we tweak it every so often until then for purely cosmetic purposes.
299
- setTimeout ( this . updateProgressBar . bind ( this ) , this . PROGRESS_BAR_INTERVAL , status , action ) ;
300
+ setTimeout ( this . updateProgressBar . bind ( this ) , this . PROGRESS_BAR_INTERVAL , action ) ;
300
301
301
302
try {
302
303
spoolOutput = await SubmitJobs . submitJclString ( session , jcl , {
303
304
jclSource : "" ,
304
- task : status ,
305
+ task : this . progressBar ,
305
306
viewAllSpoolContent : true
306
307
} ) ;
307
308
}
308
309
catch ( error ) {
309
- status . stageName = TaskStage . FAILED ;
310
+ this . progressBar . stageName = TaskStage . FAILED ;
310
311
throw new Error ( "Failure occurred submitting DFHDPLOY JCL for JOBID " + this . jobId + ": '" + error . message +
311
- "'. Most recent status update: '" + status . statusMessage + "'." ) ;
312
+ "'. Most recent status update: '" + this . progressBar . statusMessage + "'." ) ;
312
313
}
313
314
314
315
// Find the output
@@ -317,9 +318,9 @@ export class BundleDeployer {
317
318
if ( file . ddName === "SYSTSPRT" && file . stepName === "DFHDPLOY" ) {
318
319
319
320
if ( file . data === undefined || file . data . length === 0 ) {
320
- status . stageName = TaskStage . FAILED ;
321
+ this . progressBar . stageName = TaskStage . FAILED ;
321
322
throw new Error ( "DFHDPLOY did not generate any output for JOBID " + this . jobId +
322
- ". Most recent status update: '" + status . statusMessage + "'." ) ;
323
+ ". Most recent status update: '" + this . progressBar . statusMessage + "'." ) ;
323
324
}
324
325
325
326
// log the full output for serviceability to the log
@@ -329,40 +330,40 @@ export class BundleDeployer {
329
330
}
330
331
331
332
// Finish the progress bar
332
- status . statusMessage = "Completed DFHDPLOY" ;
333
- this . params . response . progress . endBar ( ) ;
333
+ this . progressBar . statusMessage = "Completed DFHDPLOY" ;
334
+ this . endProgressBar ( ) ;
334
335
335
336
// Did DFHDPLOY fail?
336
337
if ( file . data . indexOf ( "DFHRL2055I" ) > - 1 ) {
337
- status . stageName = TaskStage . FAILED ;
338
+ this . progressBar . stageName = TaskStage . FAILED ;
338
339
// log the error output to the console
339
340
this . params . response . console . log ( file . data ) ;
340
341
throw new Error ( "DFHDPLOY stopped processing for JOBID " + this . jobId + " due to an error." ) ;
341
342
}
342
343
if ( file . data . indexOf ( "DFHRL2043I" ) > - 1 ) {
343
- status . stageName = TaskStage . COMPLETE ;
344
+ this . progressBar . stageName = TaskStage . COMPLETE ;
344
345
// log the error output to the console
345
346
this . params . response . console . log ( file . data ) ;
346
347
return "DFHDPLOY completed with warnings." ;
347
348
}
348
349
if ( file . data . indexOf ( "DFHRL2012I" ) > - 1 ) {
349
- status . stageName = TaskStage . COMPLETE ;
350
+ this . progressBar . stageName = TaskStage . COMPLETE ;
350
351
// only log the output to the console if verbose output is enabled
351
352
if ( this . params . arguments . verbose ) {
352
353
this . params . response . console . log ( file . data ) ;
353
354
}
354
355
return "Bundle deployment successful." ;
355
356
}
356
357
if ( file . data . indexOf ( "DFHRL2037I" ) > - 1 ) {
357
- status . stageName = TaskStage . COMPLETE ;
358
+ this . progressBar . stageName = TaskStage . COMPLETE ;
358
359
// only log the output to the console if verbose output is enabled
359
360
if ( this . params . arguments . verbose ) {
360
361
this . params . response . console . log ( file . data ) ;
361
362
}
362
363
return "Bundle undeployment successful." ;
363
364
}
364
365
365
- status . stageName = TaskStage . FAILED ;
366
+ this . progressBar . stageName = TaskStage . FAILED ;
366
367
// log the error output to the console
367
368
this . params . response . console . log ( file . data ) ;
368
369
throw new Error ( "DFHDPLOY command completed for JOBID " + this . jobId + ", but status cannot be determined." ) ;
@@ -372,15 +373,27 @@ export class BundleDeployer {
372
373
// If we haven't found SYSTSPRT then echo JESMSGLG instead
373
374
for ( const file of spoolOutput ) {
374
375
if ( file . ddName === "JESMSGLG" ) {
375
- status . stageName = TaskStage . FAILED ;
376
+ this . progressBar . stageName = TaskStage . FAILED ;
376
377
// log the error output to the console
377
378
this . params . response . console . log ( file . data ) ;
378
379
throw new Error ( "DFHDPLOY command completed in error for JOBID " + this . jobId + " without generating SYSTSPRT output." ) ;
379
380
}
380
381
}
381
382
382
- status . stageName = TaskStage . FAILED ;
383
+ this . progressBar . stageName = TaskStage . FAILED ;
383
384
throw new Error ( "SYSTSPRT and JESMSGLG output from DFHDPLOY not found for JOBID " + this . jobId +
384
- ". Most recent status update: '" + status . statusMessage + "'." ) ;
385
+ ". Most recent status update: '" + this . progressBar . statusMessage + "'." ) ;
386
+ }
387
+
388
+ private startProgressBar ( ) {
389
+ if ( this . params . arguments . verbose !== true ) {
390
+ this . params . response . progress . startBar ( { task : this . progressBar } ) ;
391
+ }
392
+ }
393
+
394
+ private endProgressBar ( ) {
395
+ if ( this . params . arguments . verbose !== true ) {
396
+ this . params . response . progress . endBar ( ) ;
397
+ }
385
398
}
386
399
}
0 commit comments