@@ -70,11 +70,11 @@ export class BundlePusher {
70
70
// Create an SSH session
71
71
const sshSession = await this . createSshSession ( ) ;
72
72
73
- // Start a progress bar
73
+ // Start a progress bar (but only in non-verbose mode)
74
74
this . progressBar = { percentComplete : 0 ,
75
75
statusMessage : "Starting Push operation" ,
76
76
stageName : TaskStage . IN_PROGRESS } ;
77
- this . params . response . progress . startBar ( { task : this . progressBar } ) ;
77
+ this . startProgressBar ( ) ;
78
78
79
79
// Attempt to make the target bundledir
80
80
await this . makeBundleDir ( zosMFSession ) ;
@@ -103,7 +103,7 @@ export class BundlePusher {
103
103
// Run DFHDPLOY to install the bundle
104
104
await this . deployBundle ( zosMFSession , bd ) ;
105
105
106
- this . params . response . progress . endBar ( ) ;
106
+ this . endProgressBar ( ) ;
107
107
return "PUSH operation completed." ;
108
108
}
109
109
@@ -223,37 +223,36 @@ export class BundlePusher {
223
223
private async undeployExistingBundle ( zosMFSession : AbstractSession , bd : BundleDeployer ) {
224
224
// End the current progress bar so that UNDEPLOY can create its own
225
225
this . updateStatus ( "Undeploying any existing bundle from CICS" ) ;
226
- this . params . response . progress . endBar ( ) ;
226
+ this . endProgressBar ( ) ;
227
+
227
228
228
229
const targetstateLocal = this . params . arguments . targetstate ;
229
230
this . params . arguments . targetstate = "DISCARDED" ;
230
231
await bd . undeployBundle ( zosMFSession ) ;
231
232
this . params . arguments . targetstate = targetstateLocal ;
232
233
233
234
// Resume the current progress bar
234
- this . params . response . progress . endBar ( ) ;
235
+ this . endProgressBar ( ) ;
235
236
this . updateStatus ( "Undeployed existing bundle from CICS" ) ;
236
- this . params . response . progress . startBar ( { task : this . progressBar } ) ;
237
+ this . startProgressBar ( ) ;
237
238
}
238
239
239
240
private async deployBundle ( zosMFSession : AbstractSession , bd : BundleDeployer ) {
240
241
// End the current progress bar so that DEPLOY can create its own
241
242
this . updateStatus ( "Deploying the bundle to CICS" ) ;
242
- this . params . response . progress . endBar ( ) ;
243
+ this . endProgressBar ( ) ;
243
244
244
245
await bd . deployBundle ( zosMFSession ) ;
245
246
// Resume the current progress bar
246
- this . params . response . progress . endBar ( ) ;
247
+ this . endProgressBar ( ) ;
247
248
this . updateStatus ( "Deployed existing bundle to CICS" ) ;
248
- this . params . response . progress . startBar ( { task : this . progressBar } ) ;
249
+ this . startProgressBar ( ) ;
249
250
}
250
251
251
252
private sshOutput ( data : string ) {
252
253
// If verbose output is requested then log SSH output directly to the console
253
254
if ( this . params . arguments . verbose ) {
254
- this . params . response . progress . endBar ( ) ;
255
255
this . params . response . console . log ( Buffer . from ( data ) ) ;
256
- this . params . response . progress . startBar ( { task : this . progressBar } ) ;
257
256
}
258
257
this . sshOutputText += data ;
259
258
}
@@ -319,19 +318,30 @@ export class BundlePusher {
319
318
try {
320
319
this . sshOutputText = "" ;
321
320
const shell = await Shell . executeSshCwd ( sshSession , sshCommand , directory , this . sshOutput . bind ( this ) ) ;
321
+ const upperCaseOutputText = this . sshOutputText . toUpperCase ( ) ;
322
322
323
323
// Did the SSH command work? It's unclear how to tell, but for starters let's look for common
324
- // signifiers in the output text. Note that FSUM9195 implies that we've tried to delete the
324
+ // signifiers in the output text. Note that FSUM9195 can imply that we've tried to delete the
325
325
// contents of an empty directory - that's not a problem.
326
- const upperCaseOutputText = this . sshOutputText . toUpperCase ( ) ;
327
- if ( upperCaseOutputText . indexOf ( "ERROR " ) > - 1 ||
328
- ( upperCaseOutputText . indexOf ( "FSUM" ) > - 1 &&
329
- upperCaseOutputText . indexOf ( "FSUM9195" ) === - 1 ) ||
326
+
327
+ // If there any FSUM messages other than FSUM9195 then that's a problem
328
+ let otherFSUMMessages = false ;
329
+ const countFSUM = ( upperCaseOutputText . match ( / F S U M / g) || [ ] ) . length ;
330
+ const countFSUM9195 = ( upperCaseOutputText . match ( / F S U M 9 1 9 5 / g) || [ ] ) . length ;
331
+ if ( countFSUM > countFSUM9195 ) {
332
+ otherFSUMMessages = true ;
333
+ }
334
+
335
+ // Now check for other common error signifiers
336
+ if ( otherFSUMMessages ||
337
+ upperCaseOutputText . indexOf ( "ERROR " ) > - 1 ||
338
+ upperCaseOutputText . indexOf ( "EDC" ) > - 1 ||
330
339
upperCaseOutputText . indexOf ( "ERR!" ) > - 1 ) {
340
+
331
341
// if we've not already logged the output, log it now
332
342
if ( this . params . arguments . verbose !== true )
333
343
{
334
- this . params . response . console . log ( this . sshOutputText ) ;
344
+ this . params . response . console . log ( Buffer . from ( this . sshOutputText ) ) ;
335
345
}
336
346
throw new Error ( "The output from the remote command implied that an error occurred." ) ;
337
347
}
@@ -372,13 +382,13 @@ export class BundlePusher {
372
382
373
383
// A project specific .zosattributes has not been found, so use a default
374
384
const warningMsg = "WARNING: No .zosAttributes file found in the bundle directory, default values will be applied." ;
375
- this . params . response . progress . endBar ( ) ;
376
- this . params . response . console . log ( warningMsg ) ;
385
+ this . endProgressBar ( ) ;
386
+ this . params . response . console . log ( Buffer . from ( warningMsg ) ) ;
377
387
if ( this . params . arguments . silent === undefined ) {
378
388
const logger = Logger . getAppLogger ( ) ;
379
389
logger . warn ( warningMsg ) ;
380
390
}
381
- this . params . response . progress . startBar ( { task : this . progressBar } ) ;
391
+ this . startProgressBar ( ) ;
382
392
return new ZosFilesAttributes ( Bundle . getTemplateZosAttributesFile ( ) ) ;
383
393
}
384
394
@@ -388,12 +398,24 @@ export class BundlePusher {
388
398
this . progressBar . statusMessage = status ;
389
399
390
400
if ( this . params . arguments . verbose ) {
391
- this . params . response . console . log ( status + "\n" ) ;
401
+ this . params . response . console . log ( Buffer . from ( status + "\n" ) ) ;
392
402
}
393
403
394
404
if ( this . params . arguments . silent === undefined ) {
395
405
const logger = Logger . getAppLogger ( ) ;
396
406
logger . debug ( status ) ;
397
407
}
398
408
}
409
+
410
+ private startProgressBar ( ) {
411
+ if ( this . params . arguments . verbose !== true ) {
412
+ this . params . response . progress . startBar ( { task : this . progressBar } ) ;
413
+ }
414
+ }
415
+
416
+ private endProgressBar ( ) {
417
+ if ( this . params . arguments . verbose !== true ) {
418
+ this . params . response . progress . endBar ( ) ;
419
+ }
420
+ }
399
421
}
0 commit comments