diff --git a/scripts/wait-for-all-codebuild.ts b/scripts/wait-for-all-codebuild.ts index f8287657cef..ea104cc67c5 100644 --- a/scripts/wait-for-all-codebuild.ts +++ b/scripts/wait-for-all-codebuild.ts @@ -51,6 +51,7 @@ const main = async () => { const codeBuildProjectName = process.argv[4]; const codebuildWebhookTrigger = process.argv[5]; const accountForFailures: boolean = process.argv.length >= 7 && process.argv[6] === 'requirePrevJobsToSucceed'; + let jobsDependedOn: string[]; if (fs.existsSync(jobsDependedOnFilepathOrId)) { const jobsDependedOnRaw = fs.readFileSync(jobsDependedOnFilepathOrId, 'utf8'); @@ -80,14 +81,14 @@ const main = async () => { let intersectingIncompleteJobs: string[]; do { await new Promise((resolve) => setTimeout(resolve, 180 * 1000)); // sleep for 180 seconds + const failedJobsInBatch = await getFailedJobIdsFromBatchId(cb, batchId); + const intersectingFailedJobs = failedJobsInBatch.filter((jobId) => jobsDependedOn.includes(jobId)); + const batchFailed = failedJobsInBatch.length || intersectingFailedJobs.length; + console.log(`Batch triggered by ${codebuildWebhookTrigger} ${batchFailed ? 'failed' : 'succeeded'}.`); + if (accountForFailures) { - const failedJobsInBatch = await getFailedJobIdsFromBatchId(cb, batchId); - const intersectingFailedJobs = failedJobsInBatch.filter((jobId) => jobsDependedOn.includes(jobId)); console.log(`failedJobsInBatch: ${JSON.stringify(failedJobsInBatch)}`); console.log(`intersectingFailedJobs: ${JSON.stringify(intersectingFailedJobs)}`); - if (failedJobsInBatch.length || intersectingFailedJobs.length) { - console.log(`Batch triggered by ${codebuildWebhookTrigger} failed.`); - } if (intersectingFailedJobs.length > 0) { console.log(`${jobsDependedOn[0]} failed. Exiting.`); process.exit(1); diff --git a/shared-scripts.sh b/shared-scripts.sh index a57c88511a7..77b63ba8448 100644 --- a/shared-scripts.sh +++ b/shared-scripts.sh @@ -670,7 +670,7 @@ function _waitForJobs { cd ./scripts npm install -g ts-node npm install aws-sdk - ts-node ./wait-for-all-codebuild.ts $CODEBUILD_RESOLVED_SOURCE_VERSION $file_path $PROJECT_NAME $CODEBUILD_WEBHOOK_TRIGGER $account_for_failures + ts-node ./wait-for-all-codebuild.ts $CODEBUILD_RESOLVED_SOURCE_VERSION $file_path $PROJECT_NAME ${CODEBUILD_WEBHOOK_TRIGGER:-empty} $account_for_failures cd .. } function _verifyPkgCLI {