diff --git a/modules/persistence/index.ts b/modules/persistence/index.ts index 5fbf6d143..d6397dd89 100644 --- a/modules/persistence/index.ts +++ b/modules/persistence/index.ts @@ -18,6 +18,7 @@ import { upsertAssets } from './src/services/assets'; interface ModuleArgs { path: string; githubUser: string; + jobId?: string; strict: string; [props: string | number | symbol]: unknown; } @@ -30,14 +31,14 @@ const missingPathMessage = 'No path specified in arguments - please specify a bu // Load command line args into a parameterized argv const argv: ModuleArgs = minimist(process.argv.slice(2)); -const app = async (path: string, githubUser: string) => { +const app = async (path: string, githubUser: string, jobId?: string) => { try { if (!path) throw missingPathMessage; const user = githubUser || 'docs-builder-bot'; const zip = new AdmZip(path); // atomic buildId for all artifacts read by this module - fundamental assumption // that only one build will be used per run of this module. - const buildId = new mongodb.ObjectId(); + const buildId = new mongodb.ObjectId(jobId); const metadata = await metadataFromZip(zip, user); // initialize db connections to handle shared connections await snootyDb(); @@ -55,7 +56,7 @@ const app = async (path: string, githubUser: string) => { } }; -app(argv['path'], argv['githubUser']).catch(() => { +app(argv['path'], argv['githubUser'], argv['jobId']).catch(() => { console.error('Persistence Module Failure. Ending build.'); process.exit(1); }); diff --git a/src/job/productionJobHandler.ts b/src/job/productionJobHandler.ts index f9d434955..8f66d14de 100644 --- a/src/job/productionJobHandler.ts +++ b/src/job/productionJobHandler.ts @@ -134,7 +134,7 @@ export class ProductionJobHandler extends JobHandler { if (this.currJob?.buildCommands) { this.currJob.buildCommands[this.currJob.buildCommands.length - 1] = 'make get-build-dependencies'; this.currJob.buildCommands.push('make next-gen-parse'); - this.currJob.buildCommands.push('make persistence-module'); + this.currJob.buildCommands.push(`make persistence-module JOB_ID=${this.currJob._id}`); this.currJob.buildCommands.push('make next-gen-html'); this.currJob.buildCommands.push(`make oas-page-build MUT_PREFIX=${this.currJob.payload.mutPrefix}`); } diff --git a/src/job/stagingJobHandler.ts b/src/job/stagingJobHandler.ts index e77000f52..b43c49188 100644 --- a/src/job/stagingJobHandler.ts +++ b/src/job/stagingJobHandler.ts @@ -58,7 +58,9 @@ export class StagingJobHandler extends JobHandler { prepStageSpecificNextGenCommands(): void { if (this.currJob.buildCommands) { this.currJob.buildCommands[this.currJob.buildCommands.length - 1] = 'make next-gen-parse'; - this.currJob.buildCommands.push(`make persistence-module GH_USER=${this.currJob.payload.repoOwner}`); + this.currJob.buildCommands.push( + `make persistence-module GH_USER=${this.currJob.payload.repoOwner} JOB_ID=${this.currJob._id}` + ); this.currJob.buildCommands.push('make next-gen-html'); const project = this.currJob.payload.project === 'cloud-docs' ? this.currJob.payload.project : ''; const branchName = /^[a-zA-Z0-9_\-\./]+$/.test(this.currJob.payload.branchName)