Skip to content

Commit 274a6a2

Browse files
authored
Merge branch 'master' into master
2 parents 3a6425f + d05c5cc commit 274a6a2

File tree

16 files changed

+1188
-121
lines changed

16 files changed

+1188
-121
lines changed

Jenkinsfile

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
*/
1919
def RELEASE_BRANCHES = ["master"]
2020

21+
/**
22+
* Branches to send notifcations for
23+
*/
24+
def NOTIFY_BRANCHES = ["master"]
25+
26+
2127
/**
2228
* The following flags are switches to control which stages of the pipeline to be run. This is helpful when
2329
* testing a specific stage of the pipeline.
@@ -56,18 +62,18 @@ def UNIT_RESULTS = "${TEST_RESULTS_FOLDER}/unit"
5662
/**
5763
* The location of the system test results
5864
*/
59-
def SYSTEM_RESULTS = "${TEST_RESULTS_FOLDER}/system"
65+
def SYSTEM_RESULTS = "${TEST_RESULTS_FOLDER}/system"
6066

6167
/**
6268
* The name of the master branch
6369
*/
6470
def MASTER_BRANCH = "master"
6571

66-
6772
/**
68-
* A command to be run that gets the current revision pulled down
73+
* Variables to check any new commit since the previous successful commit
6974
*/
70-
def GIT_REVISION_LOOKUP = 'git log -n 1 --pretty=format:%h'
75+
def GIT_COMMIT = "null"
76+
def GIT_PREVIOUS_SUCCESSFUL_COMMIT = "null"
7177

7278
/**
7379
* This is the product name used by the build machine to store information about
@@ -86,6 +92,10 @@ def ARTIFACTORY_CREDENTIALS_ID = "c8e3aa62-5eef-4e6b-8a3f-aa1006a7ef01"
8692
// much impossible to have conditional options based on the branch :/
8793
def opts = []
8894

95+
// Setup a schedule to run build periodically
96+
// Run a build at 2.00AM everyday
97+
def CRON_STRING = BRANCH_NAME == MASTER_BRANCH ? "H 2 * * *" : ""
98+
8999
if (RELEASE_BRANCHES.contains(BRANCH_NAME)) {
90100
// Only keep 20 builds
91101
opts.push(buildDiscarder(logRotator(numToKeepStr: '20')))
@@ -109,6 +119,10 @@ pipeline {
109119
skipDefaultCheckout true
110120
}
111121

122+
triggers {
123+
cron(CRON_STRING)
124+
}
125+
112126
environment {
113127
// Environment variable for flow control. Indicates if the git source was updated by the pipeline.
114128
GIT_SOURCE_UPDATED = "false"
@@ -124,8 +138,13 @@ pipeline {
124138
stage("Clean workspace and checkout source") {
125139
steps {
126140
timeout(time: 5, unit: 'MINUTES') {
127-
cleanWs()
128-
checkout scm
141+
script {
142+
cleanWs()
143+
scmInfo = checkout scm
144+
145+
GIT_COMMIT = scmInfo.GIT_COMMIT
146+
GIT_PREVIOUS_SUCCESSFUL_COMMIT = scmInfo.GIT_PREVIOUS_SUCCESSFUL_COMMIT
147+
}
129148
}
130149
}
131150
}
@@ -158,12 +177,6 @@ pipeline {
158177
steps {
159178
timeout(time: 2, unit: 'MINUTES') {
160179
script {
161-
// We need to keep track of the current commit revision. This is to prevent the condition where
162-
// the build starts on master and another branch gets merged to master prior to version bump
163-
// commit taking place. If left unhandled, the version bump could be done on latest master branch
164-
// code which would already be ahead of this build.
165-
BUILD_REVISION = sh returnStdout: true, script: GIT_REVISION_LOOKUP
166-
167180
// This checks for the [ci skip] text. If found, the status code is 0
168181
def result = sh returnStatus: true, script: 'git log -1 | grep \'.*\\[ci skip\\].*\''
169182
if (result == 0) {
@@ -537,7 +550,7 @@ pipeline {
537550
return BRANCH_NAME == MASTER_BRANCH
538551
}
539552
expression {
540-
return GIT_COMMIT =! GIT_PREVIOUS_SUCCESSFUL_COMMIT
553+
return GIT_COMMIT != GIT_PREVIOUS_SUCCESSFUL_COMMIT
541554
}
542555
}
543556
}
@@ -588,10 +601,10 @@ pipeline {
588601
return PIPELINE_CONTROL.deploy
589602
}
590603
expression {
591-
return BRANCH_NAME == MASTER_BRANCH
604+
return BRANCH_NAME == MASTER_BRANCH
592605
}
593606
expression {
594-
return GIT_COMMIT =! GIT_PREVIOUS_SUCCESSFUL_COMMIT
607+
return GIT_COMMIT != GIT_PREVIOUS_SUCCESSFUL_COMMIT
595608
}
596609
}
597610
}
@@ -611,8 +624,7 @@ pipeline {
611624
if (BRANCH_NAME == MASTER_BRANCH) {
612625
echo "publishing next to $TEST_NPM_REGISTRY"
613626
sh "npm publish --tag next"
614-
}
615-
else {
627+
} else {
616628
echo "publishing latest to $TEST_NPM_REGISTRY"
617629
sh "npm publish --tag latest"
618630
}
@@ -624,4 +636,20 @@ pipeline {
624636
}
625637
}
626638
}
639+
post {
640+
unsuccessful {
641+
script {
642+
if (NOTIFY_BRANCHES.contains(BRANCH_NAME)) {
643+
slackSend (channel: '#cics-node-dev', message: "${env.JOB_NAME} #${env.BUILD_NUMBER} completed - ${currentBuild.result} (<${env.BUILD_URL}|Open>)", tokenCredentialId: 'slack-cics-node-dev')
644+
}
645+
}
646+
}
647+
fixed {
648+
script {
649+
if (NOTIFY_BRANCHES.contains(BRANCH_NAME)) {
650+
slackSend (channel: '#cics-node-dev', message: "${env.JOB_NAME} #${env.BUILD_NUMBER} completed - Back to normal (<${env.BUILD_URL}|Open>)", tokenCredentialId: 'slack-cics-node-dev')
651+
}
652+
}
653+
}
654+
}
627655
}

__tests__/api/BundleDeploy/BundleDeployer.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import { BundleDeployer } from "../../../src/api/BundleDeploy/BundleDeployer";
1313
import { IHandlerParameters, TaskStage } from "@zowe/imperative";
1414
import * as DeployBundleDefinition from "../../../src/cli/deploy/bundle/DeployBundle.definition";
15-
import * as fse from "fs-extra";
1615
import { ZosmfSession, SubmitJobs, List } from "@zowe/cli";
1716

1817

@@ -69,6 +68,9 @@ describe("BundleDeployer01", () => {
6968
});
7069
afterEach(() => {
7170
jest.restoreAllMocks();
71+
(DEFAULT_PARAMTERS.response.progress.startBar as jest.Mock).mockReset();
72+
(DEFAULT_PARAMTERS.response.progress.endBar as jest.Mock).mockReset();
73+
7274
});
7375
it("should complain with missing zOSMF profile for deploy", async () => {
7476
createSpy.mockImplementationOnce(() => { throw new Error( "Injected Create error" ); });
@@ -124,7 +126,7 @@ describe("BundleDeployer01", () => {
124126
submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce((session: any, jcl: string, parms: any) => {
125127
parms.task.statusMessage = "Waiting for JOB12345 to enter OUTPUT";
126128
parms.task.stageName = TaskStage.IN_PROGRESS;
127-
const expectedMsg = "Running DFHDPLOY (DEPLOY), job JOB12345";
129+
const expectedMsg = "Running DFHDPLOY (DEPLOY), jobid JOB12345";
128130
// wait 1.5 seconds
129131
return new Promise((resolve, reject) => {
130132
setTimeout(() => {
@@ -506,6 +508,24 @@ describe("BundleDeployer01", () => {
506508
parms.arguments.verbose = false;
507509
await testUndeployJCL(parms);
508510
});
511+
512+
it("should use task passed as parameter on deploy", async () => {
513+
submitSpy.mockImplementationOnce(() => [{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2012I"}] );
514+
515+
let parms: IHandlerParameters;
516+
parms = DEFAULT_PARAMTERS;
517+
setCommonParmsForDeployTests(parms);
518+
parms.arguments.csdgroup = "12345678";
519+
520+
const bd = new BundleDeployer(parms);
521+
const task = { percentComplete: 0, stageName: TaskStage.NOT_STARTED, statusMessage: ""};
522+
const response = await bd.deployBundle(undefined, task);
523+
expect(task.stageName).toEqual(TaskStage.COMPLETE);
524+
expect(task.statusMessage).toEqual("Completed DFHDPLOY");
525+
expect(parms.response.progress.startBar).toHaveBeenCalledTimes(0);
526+
expect(parms.response.progress.endBar).toHaveBeenCalledTimes(0);
527+
528+
});
509529
});
510530

511531
async function runDeployTestWithError() {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 1`] = `"DFHRL2055I"`;
44

5-
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 2`] = `"DFHDPLOY stopped processing for JOBID UNKNOWN due to an error."`;
5+
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 2`] = `"DFHDPLOY stopped processing for jobid UNKNOWN due to an error."`;
66

7-
exports[`BundleDeployer01 should complain if SYSTSPRT not found 1`] = `"SYSTSPRT and JESMSGLG output from DFHDPLOY not found for JOBID UNKNOWN. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
7+
exports[`BundleDeployer01 should complain if SYSTSPRT not found 1`] = `"SYSTSPRT and JESMSGLG output from DFHDPLOY not found for jobid UNKNOWN. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
88

99
exports[`BundleDeployer01 should complain if cicshlq not found 1`] = `"Validation of --cicshlq dataset failed: Injected CICSHLQ error"`;
1010

@@ -16,7 +16,7 @@ exports[`BundleDeployer01 should complain if cpsmhlq not found2 1`] = `"EYU9ABSI
1616

1717
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `" "`;
1818

19-
exports[`BundleDeployer01 should complain if status can't be determined 2`] = `"DFHDPLOY command completed for JOBID UNKNOWN, but status cannot be determined."`;
19+
exports[`BundleDeployer01 should complain if status can't be determined 2`] = `"DFHDPLOY command completed for jobid UNKNOWN, but status cannot be determined."`;
2020

2121
exports[`BundleDeployer01 should complain with missing zOSMF profile for deploy 1`] = `"Injected Create error"`;
2222

@@ -32,7 +32,7 @@ exports[`BundleDeployer01 should fail with overlong jobcard 1`] = `"--jobcard pa
3232

3333
exports[`BundleDeployer01 should failover to JESMSGLG if SYSTSPRT not found 1`] = `"undefined"`;
3434

35-
exports[`BundleDeployer01 should failover to JESMSGLG if SYSTSPRT not found 2`] = `"DFHDPLOY command completed in error for JOBID UNKNOWN without generating SYSTSPRT output."`;
35+
exports[`BundleDeployer01 should failover to JESMSGLG if SYSTSPRT not found 2`] = `"DFHDPLOY command completed in error for jobid UNKNOWN without generating SYSTSPRT output."`;
3636

3737
exports[`BundleDeployer01 should generate deploy JCL for AVAILABLE 1`] = `
3838
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
@@ -369,9 +369,9 @@ UNDEPLOY BUNDLE(12345678)
369369
"
370370
`;
371371

372-
exports[`BundleDeployer01 should handle failure during submitjobs processing 1`] = `"Failure occurred submitting DFHDPLOY JCL for JOBID UNKNOWN: 'Injected Submit error'. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
372+
exports[`BundleDeployer01 should handle failure during submitjobs processing 1`] = `"Failure occurred submitting DFHDPLOY JCL for jobid UNKNOWN: 'Injected Submit error'. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
373373

374-
exports[`BundleDeployer01 should include the JOBID in an error 1`] = `"Failure occurred submitting DFHDPLOY JCL for JOBID JOB12345: 'Injected submit error'. Most recent status update: 'Running DFHDPLOY (DEPLOY), job JOB12345'."`;
374+
exports[`BundleDeployer01 should include the JOBID in an error 1`] = `"Failure occurred submitting DFHDPLOY JCL for jobid JOB12345: 'Injected submit error'. Most recent status update: 'Running DFHDPLOY (DEPLOY), jobid JOB12345'."`;
375375

376376
exports[`BundleDeployer01 should support long bundledir 1`] = `
377377
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
@@ -594,7 +594,7 @@ DEPLOY BUNDLE(12345678)
594594
"
595595
`;
596596

597-
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 1`] = `"DFHDPLOY did not generate any output for JOBID UNKNOWN. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
597+
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 1`] = `"DFHDPLOY did not generate any output for jobid UNKNOWN. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
598598

599599
exports[`BundleDeployer01 should undeploy successfully 1`] = `"Bundle undeployment successful."`;
600600

0 commit comments

Comments
 (0)