Skip to content

Commit d2ad4fe

Browse files
Merge pull request #28 from pcoop/branch1
submitjobs status on errors
2 parents 6007d0a + 773f579 commit d2ad4fe

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

__tests__/api/BundleDeploy/__snapshots__/BundleDeployer.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports[`BundleDeployer01 should complain if status can't be determined 1`] = `"
1616

1717
exports[`BundleDeployer01 should complain if status can't be determined 2`] = `"DFHDPLOY command completed, but status cannot be determined."`;
1818

19-
exports[`BundleDeployer01 should complain of SYSTSPRT not found 1`] = `"SYSTSPRT output from DFHDPLOY not found."`;
19+
exports[`BundleDeployer01 should complain of SYSTSPRT not found 1`] = `"SYSTSPRT output from DFHDPLOY not found. Most recent status update: ''."`;
2020

2121
exports[`BundleDeployer01 should complain with missing zOSMF profile for deploy 1`] = `"Expect Error: Required parameter 'hostname' must be defined"`;
2222

@@ -220,7 +220,7 @@ UNDEPLOY BUNDLE(12345678)
220220
"
221221
`;
222222

223-
exports[`BundleDeployer01 should handle failure during submitjobs processing 1`] = `"Failure occurred submitting DFHDPLOY JCL: Cannot read property 'hostname' of undefined"`;
223+
exports[`BundleDeployer01 should handle failure during submitjobs processing 1`] = `"Failure occurred submitting DFHDPLOY JCL: 'Cannot read property 'hostname' of undefined'. Most recent status update: ''."`;
224224

225225
exports[`BundleDeployer01 should support long bundledir 1`] = `"DFHRL2037I"`;
226226

@@ -250,7 +250,7 @@ DEPLOY BUNDLE(12345678)
250250

251251
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 1`] = `"undefined"`;
252252

253-
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 2`] = `"DFHDPLOY did not generate any output."`;
253+
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 2`] = `"DFHDPLOY did not generate any output. Most recent status update: ''."`;
254254

255255
exports[`BundleDeployer01 should undeploy successfully 1`] = `"DFHRL2037I"`;
256256

__tests__/cli/deploy/bundle/DeployBundle.handler.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ describe("bundle Handler", () => {
374374
it("should complain if jobcard omits JOB ", async () => {
375375
await testJobcardError("//wibble boj", "--jobcard parameter does not have JOB keyword after the jobname. Expected 'JOB' but found 'boj'");
376376
});
377+
it("should complain if jobcard omits JOB 2", async () => {
378+
await testJobcardError("//wibble", "--jobcard parameter does not have JOB keyword after the jobname.");
379+
});
377380
it("should complain if zosmf profile not found", async () => {
378381

379382
const params = Object.assign({}, ...[DEFAULT_PARAMETERS]);

src/api/BundleDeploy/BundleDeployer.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
"use strict";
1313

14-
import { IHandlerParameters, Logger, ImperativeError, Session } from "@brightside/imperative";
14+
import { IHandlerParameters, Logger, ImperativeError, Session, ITaskWithStatus, TaskStage } from "@brightside/imperative";
1515
import { ZosmfSession, SubmitJobs, List } from "@brightside/core";
1616
import { ParmValidator } from "./ParmValidator";
1717

@@ -205,12 +205,17 @@ export class BundleDeployer {
205205

206206
private async submitJCL(jcl: string, session: Session): Promise<string> {
207207
let spoolOutput: any;
208+
const status: ITaskWithStatus = { percentComplete: 0, statusMessage: "", stageName: TaskStage.NOT_STARTED };
208209
try {
209-
spoolOutput = await SubmitJobs.submitJclString(session, jcl,
210-
{ jclSource: "", viewAllSpoolContent: true });
210+
spoolOutput = await SubmitJobs.submitJclString(session, jcl, {
211+
jclSource: "",
212+
task: status,
213+
viewAllSpoolContent: true
214+
});
211215
}
212216
catch (error) {
213-
throw new Error("Failure occurred submitting DFHDPLOY JCL: " + error.message);
217+
throw new Error("Failure occurred submitting DFHDPLOY JCL: '" + error.message +
218+
"'. Most recent status update: '" + status.statusMessage + "'.");
214219
}
215220

216221
// Find the output
@@ -224,7 +229,7 @@ export class BundleDeployer {
224229
logger.debug(file.data);
225230

226231
if (file.data === undefined || file.data.length === 0) {
227-
throw new Error("DFHDPLOY did not generate any output.");
232+
throw new Error("DFHDPLOY did not generate any output. Most recent status update: '" + status.statusMessage + "'.");
228233
}
229234

230235
// Did DFHDPLOY fail?
@@ -245,6 +250,6 @@ export class BundleDeployer {
245250
}
246251
}
247252

248-
throw new Error("SYSTSPRT output from DFHDPLOY not found.");
253+
throw new Error("SYSTSPRT output from DFHDPLOY not found. Most recent status update: '" + status.statusMessage + "'.");
249254
}
250255
}

src/api/BundleDeploy/ParmValidator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ export class ParmValidator {
302302
throw new Error("--jobcard parameter does not start with a suitable jobname: '" + jobname + " '");
303303
}
304304

305+
// Check that there is a second word
306+
if (firstPartParts.length < 2) {
307+
throw new Error("--jobcard parameter does not have JOB keyword after the jobname.");
308+
}
309+
305310
// check the second word is 'JOB'
306311
const jobkeyword = firstPartParts[1].trim();
307312
if (jobkeyword !== "JOB") {

0 commit comments

Comments
 (0)