From ff446ae5c25fdd7270e104b584d69c0d36883a43 Mon Sep 17 00:00:00 2001 From: Dayanand Sagar Date: Tue, 19 Nov 2024 10:27:37 -0800 Subject: [PATCH] fix(3228): GH status for virtual job PR build always shows as pending (#632) --- lib/build.js | 91 ++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/lib/build.js b/lib/build.js index 5e56c922..7ca9bf65 100644 --- a/lib/build.js +++ b/lib/build.js @@ -526,55 +526,56 @@ class BuildModel extends BaseModel { return this.job.then(job => Promise.all([job.pipeline, job.prNum]) .then(([pipeline, prNum]) => - getBlockedByIds(pipeline, job) - .then(blockedBy => { - const config = { - build: this, - buildId: this.id, - eventId: this.eventId, - jobId: job.id, - jobState: job.state, - jobArchived: job.archived, - jobName: job.name, - annotations: hoek.reach(job.permutations[0], 'annotations', { default: {} }), - blockedBy, - pipelineId: pipeline.id, - pipeline: { - id: pipeline.id, - name: pipeline.name, - scmContext: pipeline.scmContext, - configPipelineId: pipeline.configPipelineId - }, - causeMessage: causeMessage || '', - freezeWindows: hoek.reach(job.permutations[0], 'freezeWindows', { default: [] }), - apiUri: this[apiUri], - container: this.container, - tokenGen: this[tokenGen], - token: getToken(this, job, pipeline), - isPR: job.isPR(), - prParentJobId: job.prParentJobId - }; - - if (template && !hoek.deepEqual(template, {})) { - config.template = template; - } + getBlockedByIds(pipeline, job).then(blockedBy => { + const config = { + build: this, + buildId: this.id, + eventId: this.eventId, + jobId: job.id, + jobState: job.state, + jobArchived: job.archived, + jobName: job.name, + annotations: hoek.reach(job.permutations[0], 'annotations', { default: {} }), + blockedBy, + pipelineId: pipeline.id, + pipeline: { + id: pipeline.id, + name: pipeline.name, + scmContext: pipeline.scmContext, + configPipelineId: pipeline.configPipelineId + }, + causeMessage: causeMessage || '', + freezeWindows: hoek.reach(job.permutations[0], 'freezeWindows', { default: [] }), + apiUri: this[apiUri], + container: this.container, + tokenGen: this[tokenGen], + token: getToken(this, job, pipeline), + isPR: job.isPR(), + prParentJobId: job.prParentJobId + }; - if (prNum) { - config.prNum = prNum; - } + if (template && !hoek.deepEqual(template, {})) { + config.template = template; + } - if (this.buildClusterName) { - config.buildClusterName = this.buildClusterName; - } + if (prNum) { + config.prNum = prNum; + } - if (hoek.reach(job.permutations[0], 'provider')) { - config.provider = job.permutations[0].provider; - } + if (this.buildClusterName) { + config.buildClusterName = this.buildClusterName; + } - return this[executor].start(config); - }) - .then(() => this.updateCommitStatus(pipeline)) - ) // update github + if (hoek.reach(job.permutations[0], 'provider')) { + config.provider = job.permutations[0].provider; + } + + return Promise.all([ + this[executor].start(config), + this.updateCommitStatus(pipeline) // update github + ]); + }) + ) .then(() => this) ); }