From 9079f4ba93e83fefcae922adafece478ee25955a Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 7 Jun 2024 10:03:16 +0000 Subject: [PATCH 01/14] gitlab hosting connector with good current job id return --- .../plugins/server/GitlabHostingConnector.ts | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 26e21219c..70a6f1d3d 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -80,8 +80,8 @@ export default class GitlabHostingConnector extends GitlabConnector implements H // Update the job status if(status === JobStatus.SUCCESS) { /* Squash and tag the commits */ - const succes = await this.createTag(session, websiteId, job, { startJob, jobSuccess, jobError }) - if(!succes) { + const successTag = await this.createTag(session, websiteId, job, { startJob, jobSuccess, jobError }) + if(successTag === 'failed') { // jobError will have been called in createTag return } @@ -100,7 +100,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H job.logs[0].push(`Page URL: ${pageUrl}`) job.message = 'Getting the deployment logs URL...' job.logs[0].push(job.message) - const gitlabJobLogsUrl = await this.getGitlabJobLogsUrl(session, websiteId, adminUrl) + const gitlabJobLogsUrl = await this.getGitlabJobLogsUrl(session, websiteId, job, { startJob, jobSuccess, jobError }, adminUrl, successTag) job.logs[0].push(`Deployment logs URL: ${gitlabJobLogsUrl}`) const message = `

Your website is now live here.

@@ -146,12 +146,32 @@ export default class GitlabHostingConnector extends GitlabConnector implements H return `${projectUrl}/pages` } - async getGitlabJobLogsUrl(session: GitlabSession, websiteId: WebsiteId, projectUrl: string): Promise { - const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') - return `${projectUrl}/-/jobs/${jobs[0].id}` + async getGitlabJobLogsUrl(session: GitlabSession, websiteId: WebsiteId, job: PublicationJobData, { startJob, jobSuccess, jobError }: JobManager, projectUrl: string, tag): Promise { + let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') + // waiting for the job corresponding to the current tag + let i = 0 + setTimeout (() => { + while (jobs[0].ref !== tag && i<20) { + jobs = this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') + i++ + } + }, 100) + + // return jobs page or job id page following timer (avoiding infinite loop) + if ( i===20 ) { + console.error('unable to get job id, waiting for ', i+1, ' cycles') + jobError(job.jobId, 'Failed to get job id') + job.message = 'Unable to get job id' + job.logs[0].push(job.message) + return `${projectUrl}/-/jobs/` + } + else { + console.log('job id obtained in ', i+1, ' cycles') + return `${projectUrl}/-/jobs/${jobs[0].id}` + } } - async createTag(session: GitlabSession, websiteId: WebsiteId, job: JobData, { startJob, jobSuccess, jobError }: JobManager): Promise { + async createTag(session: GitlabSession, websiteId: WebsiteId, job: JobData, { startJob, jobSuccess, jobError }: JobManager): Promise { const projectId = websiteId // Assuming websiteId corresponds to GitLab project ID // Fetch the latest tag and determine the new tag @@ -166,7 +186,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H } catch (error) { console.error('Error during fetching latest tag:', error.message) jobError(job.jobId, `Failed to fetch latest tag: ${error.message}`) - return false + return 'Failed' } // Create a new tag @@ -180,9 +200,10 @@ export default class GitlabHostingConnector extends GitlabConnector implements H } catch (error) { console.error('Error during creating new tag:', error.message) jobError(job.jobId, `Failed to create new tag: ${error.message}`) - return false + return 'Failed' } - return true + // return new tag + return newTag } } From 972765fd33155d442d2377f4bd996c35775425ca Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 7 Jun 2024 10:17:19 +0000 Subject: [PATCH 02/14] gitlab hosting connector with good current job id return 2 --- src/ts/plugins/server/GitlabHostingConnector.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 70a6f1d3d..12a1954e8 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -150,12 +150,12 @@ export default class GitlabHostingConnector extends GitlabConnector implements H let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') // waiting for the job corresponding to the current tag let i = 0 - setTimeout (() => { - while (jobs[0].ref !== tag && i<20) { - jobs = this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') - i++ - } - }, 100) + setTimeout (() => { + while (jobs[0].ref !== tag && i<20) { + jobs = this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') + i++ + } + }, 100) // return jobs page or job id page following timer (avoiding infinite loop) if ( i===20 ) { From 7e440cc91c80820f8f733d008eaf9b84d6b9683c Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 7 Jun 2024 10:25:06 +0000 Subject: [PATCH 03/14] gitlab hosting connector with good current job id return v3 --- src/ts/plugins/server/GitlabHostingConnector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 12a1954e8..674be4863 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -81,7 +81,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H if(status === JobStatus.SUCCESS) { /* Squash and tag the commits */ const successTag = await this.createTag(session, websiteId, job, { startJob, jobSuccess, jobError }) - if(successTag === 'failed') { + if(successTag === 'Failed') { // jobError will have been called in createTag return } From 8bdf893c6129ab0daebfd1a3fdbd35b198902861 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 11 Jun 2024 09:49:03 +0000 Subject: [PATCH 04/14] with setTimout problem corrected --- .../plugins/server/GitlabHostingConnector.ts | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 674be4863..aae6f0403 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -29,6 +29,7 @@ import { JobManager } from '../../server/jobs' import { join } from 'path' import { ServerConfig } from '../../server/config' import { stat } from 'fs' +import { setTimeout } from 'timers/promises' export default class GitlabHostingConnector extends GitlabConnector implements HostingConnector { @@ -81,7 +82,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H if(status === JobStatus.SUCCESS) { /* Squash and tag the commits */ const successTag = await this.createTag(session, websiteId, job, { startJob, jobSuccess, jobError }) - if(successTag === 'Failed') { + if(!successTag) { // jobError will have been called in createTag return } @@ -146,32 +147,25 @@ export default class GitlabHostingConnector extends GitlabConnector implements H return `${projectUrl}/pages` } + // waiting for the job corresponding to the current tag async getGitlabJobLogsUrl(session: GitlabSession, websiteId: WebsiteId, job: PublicationJobData, { startJob, jobSuccess, jobError }: JobManager, projectUrl: string, tag): Promise { - let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') - // waiting for the job corresponding to the current tag let i = 0 - setTimeout (() => { - while (jobs[0].ref !== tag && i<20) { - jobs = this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') - i++ - } - }, 100) + do { + i++ + let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') + if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} + await setTimeout(5) + } while (i<19) - // return jobs page or job id page following timer (avoiding infinite loop) - if ( i===20 ) { - console.error('unable to get job id, waiting for ', i+1, ' cycles') - jobError(job.jobId, 'Failed to get job id') - job.message = 'Unable to get job id' - job.logs[0].push(job.message) - return `${projectUrl}/-/jobs/` - } - else { - console.log('job id obtained in ', i+1, ' cycles') - return `${projectUrl}/-/jobs/${jobs[0].id}` - } + // failed in timelaps allowed (avoiding infinite loop) + console.error('unable to get job id, waiting for ', i+1, ' cycles') + jobError(job.jobId, 'Failed to get job id') + job.message = 'Unable to get job id' + job.logs[0].push(job.message) + return `${projectUrl}/-/jobs/` } - async createTag(session: GitlabSession, websiteId: WebsiteId, job: JobData, { startJob, jobSuccess, jobError }: JobManager): Promise { + async createTag(session: GitlabSession, websiteId: WebsiteId, job: JobData, { startJob, jobSuccess, jobError }: JobManager): Promise { const projectId = websiteId // Assuming websiteId corresponds to GitLab project ID // Fetch the latest tag and determine the new tag @@ -186,7 +180,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H } catch (error) { console.error('Error during fetching latest tag:', error.message) jobError(job.jobId, `Failed to fetch latest tag: ${error.message}`) - return 'Failed' + return null } // Create a new tag @@ -200,7 +194,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H } catch (error) { console.error('Error during creating new tag:', error.message) jobError(job.jobId, `Failed to create new tag: ${error.message}`) - return 'Failed' + return null } // return new tag return newTag From a845e0810816b85d82795f3e987f5cc7e6458e74 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 11 Jun 2024 09:52:32 +0000 Subject: [PATCH 05/14] with setTimout problem corrected 2 --- src/ts/plugins/server/GitlabHostingConnector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index aae6f0403..b5bbfb184 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -152,7 +152,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H let i = 0 do { i++ - let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') + const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} await setTimeout(5) } while (i<19) From 84ca8ec166bd5cbfba0caed35720b8a22bb8e15f Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 13 Jun 2024 15:41:07 +0000 Subject: [PATCH 06/14] with setTimout problem corrected 3 --- src/ts/plugins/server/GitlabHostingConnector.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index b5bbfb184..93884b33f 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -149,16 +149,14 @@ export default class GitlabHostingConnector extends GitlabConnector implements H // waiting for the job corresponding to the current tag async getGitlabJobLogsUrl(session: GitlabSession, websiteId: WebsiteId, job: PublicationJobData, { startJob, jobSuccess, jobError }: JobManager, projectUrl: string, tag): Promise { - let i = 0 + const t0 = Date.now() do { - i++ const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} - await setTimeout(5) - } while (i<19) + await setTimeout(5000) + } while ((Date.now() - t0) < 15000) // failed in timelaps allowed (avoiding infinite loop) - console.error('unable to get job id, waiting for ', i+1, ' cycles') jobError(job.jobId, 'Failed to get job id') job.message = 'Unable to get job id' job.logs[0].push(job.message) From 5176792ba761735c40aed24288ad1f87962d92e0 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 13 Jun 2024 16:07:19 +0000 Subject: [PATCH 07/14] with setTimout problem corrected 3 --- src/ts/plugins/server/GitlabHostingConnector.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 93884b33f..4687981be 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -155,7 +155,6 @@ export default class GitlabHostingConnector extends GitlabConnector implements H if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} await setTimeout(5000) } while ((Date.now() - t0) < 15000) - // failed in timelaps allowed (avoiding infinite loop) jobError(job.jobId, 'Failed to get job id') job.message = 'Unable to get job id' From c0ce07d5d97a1332192cce9387be1eaed88ac467 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 13 Jun 2024 16:13:32 +0000 Subject: [PATCH 08/14] with setTimout problem corrected 3 --- src/ts/plugins/server/GitlabHostingConnector.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 4687981be..93884b33f 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -155,6 +155,7 @@ export default class GitlabHostingConnector extends GitlabConnector implements H if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} await setTimeout(5000) } while ((Date.now() - t0) < 15000) + // failed in timelaps allowed (avoiding infinite loop) jobError(job.jobId, 'Failed to get job id') job.message = 'Unable to get job id' From 5bd9085691b963632f9fdfb2abfb992c4482e9a2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 13 Jun 2024 16:19:53 +0000 Subject: [PATCH 09/14] with setTimout problem corrected 4 --- src/ts/plugins/server/GitlabHostingConnector.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 93884b33f..9806973ce 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -151,7 +151,12 @@ export default class GitlabHostingConnector extends GitlabConnector implements H async getGitlabJobLogsUrl(session: GitlabSession, websiteId: WebsiteId, job: PublicationJobData, { startJob, jobSuccess, jobError }: JobManager, projectUrl: string, tag): Promise { const t0 = Date.now() do { +<<<<<<< HEAD const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') +======= + i++ + let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') +>>>>>>> parent of a845e081 (with setTimout problem corrected 2) if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} await setTimeout(5000) } while ((Date.now() - t0) < 15000) From 1488bd890a77d41b5ebb4b7c65df64a1649fea75 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 14 Jun 2024 07:01:53 +0000 Subject: [PATCH 10/14] with setTimout problem corrected 4 --- src/ts/plugins/server/GitlabHostingConnector.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 9806973ce..35dfa42eb 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -149,19 +149,24 @@ export default class GitlabHostingConnector extends GitlabConnector implements H // waiting for the job corresponding to the current tag async getGitlabJobLogsUrl(session: GitlabSession, websiteId: WebsiteId, job: PublicationJobData, { startJob, jobSuccess, jobError }: JobManager, projectUrl: string, tag): Promise { - const t0 = Date.now() + let i = 0 do { <<<<<<< HEAD +<<<<<<< HEAD +======= + i++ +>>>>>>> parent of 84ca8ec1 (with setTimout problem corrected 3) const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') ======= i++ let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') >>>>>>> parent of a845e081 (with setTimout problem corrected 2) if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} - await setTimeout(5000) - } while ((Date.now() - t0) < 15000) + await setTimeout(5) + } while (i<19) // failed in timelaps allowed (avoiding infinite loop) + console.error('unable to get job id, waiting for ', i+1, ' cycles') jobError(job.jobId, 'Failed to get job id') job.message = 'Unable to get job id' job.logs[0].push(job.message) From c1c292fda0193aa1f28d1c62bb4f305ded587db6 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 14 Jun 2024 07:11:39 +0000 Subject: [PATCH 11/14] with setTimout problem corrected 5 --- src/ts/plugins/server/GitlabHostingConnector.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 35dfa42eb..0a72a8080 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -153,6 +153,10 @@ export default class GitlabHostingConnector extends GitlabConnector implements H do { <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= + i++ +>>>>>>> parent of 84ca8ec1 (with setTimout problem corrected 3) ======= i++ >>>>>>> parent of 84ca8ec1 (with setTimout problem corrected 3) From 8258b0140b51f0a623ff6877aeb3599bc6728c60 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 14 Jun 2024 07:12:19 +0000 Subject: [PATCH 12/14] with setTimout problem corrected 5 --- src/ts/plugins/server/GitlabHostingConnector.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 0a72a8080..fb19bf1d1 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -154,17 +154,16 @@ export default class GitlabHostingConnector extends GitlabConnector implements H <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= i++ >>>>>>> parent of 84ca8ec1 (with setTimout problem corrected 3) ======= i++ >>>>>>> parent of 84ca8ec1 (with setTimout problem corrected 3) - const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') ======= - i++ - let jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') ->>>>>>> parent of a845e081 (with setTimout problem corrected 2) +>>>>>>> parent of 5bd90856 (with setTimout problem corrected 4) + const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} await setTimeout(5) } while (i<19) From f95a2eae837f26080f87d55310133aed13816d1e Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 14 Jun 2024 07:14:09 +0000 Subject: [PATCH 13/14] with setTimout problem corrected 6 --- .../plugins/server/GitlabHostingConnector.ts | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index fb19bf1d1..93884b33f 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -149,27 +149,14 @@ export default class GitlabHostingConnector extends GitlabConnector implements H // waiting for the job corresponding to the current tag async getGitlabJobLogsUrl(session: GitlabSession, websiteId: WebsiteId, job: PublicationJobData, { startJob, jobSuccess, jobError }: JobManager, projectUrl: string, tag): Promise { - let i = 0 + const t0 = Date.now() do { -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -======= - i++ ->>>>>>> parent of 84ca8ec1 (with setTimout problem corrected 3) -======= - i++ ->>>>>>> parent of 84ca8ec1 (with setTimout problem corrected 3) -======= ->>>>>>> parent of 5bd90856 (with setTimout problem corrected 4) const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} - await setTimeout(5) - } while (i<19) + await setTimeout(5000) + } while ((Date.now() - t0) < 15000) // failed in timelaps allowed (avoiding infinite loop) - console.error('unable to get job id, waiting for ', i+1, ' cycles') jobError(job.jobId, 'Failed to get job id') job.message = 'Unable to get job id' job.logs[0].push(job.message) From 40692212b482d1371049fa409be1126cb2bbfcae Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 16 Jun 2024 17:05:57 +0000 Subject: [PATCH 14/14] with timer in variables --- src/ts/plugins/server/GitlabConnector.ts | 3 ++- src/ts/plugins/server/GitlabHostingConnector.ts | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ts/plugins/server/GitlabConnector.ts b/src/ts/plugins/server/GitlabConnector.ts index fb9f6aced..97738bec5 100644 --- a/src/ts/plugins/server/GitlabConnector.ts +++ b/src/ts/plugins/server/GitlabConnector.ts @@ -39,6 +39,7 @@ export interface GitlabOptions { repoPrefix: string scope: string domain: string + timeOut: number } export interface GitlabToken { @@ -201,7 +202,7 @@ export default class GitlabConnector implements StorageConnector { if(!this.options.clientId) throw new Error('Missing Gitlab client ID') if(!this.options.clientSecret) throw new Error('Missing Gitlab client secret') if(!this.options.domain) throw new Error('Missing Gitlab domain') - + if(!this.options.timeOut) this.options.timeOut = 15000 /* default value */ } // ** diff --git a/src/ts/plugins/server/GitlabHostingConnector.ts b/src/ts/plugins/server/GitlabHostingConnector.ts index 93884b33f..dc2ca073e 100644 --- a/src/ts/plugins/server/GitlabHostingConnector.ts +++ b/src/ts/plugins/server/GitlabHostingConnector.ts @@ -26,11 +26,11 @@ import GitlabConnector, { GitlabOptions, GitlabSession} from './GitlabConnector' import { HostingConnector, ConnectorFile } from '../../server/connectors/connectors' import { ConnectorType, WebsiteId, JobData, JobStatus, PublicationJobData } from '../../types' import { JobManager } from '../../server/jobs' -import { join } from 'path' import { ServerConfig } from '../../server/config' -import { stat } from 'fs' import { setTimeout } from 'timers/promises' +const waitTimeOut = 5000 /* for wait loop in job pages getting */ + export default class GitlabHostingConnector extends GitlabConnector implements HostingConnector { displayName = 'Gitlab hosting' @@ -153,8 +153,8 @@ export default class GitlabHostingConnector extends GitlabConnector implements H do { const jobs = await this.callApi(session, `api/v4/projects/${websiteId}/jobs`, 'GET') if (jobs[0].ref === tag) {return `${projectUrl}/-/jobs/${jobs[0].id}`} - await setTimeout(5000) - } while ((Date.now() - t0) < 15000) + await setTimeout(waitTimeOut) + } while ((Date.now() - t0) < this.options.timeOut) // failed in timelaps allowed (avoiding infinite loop) jobError(job.jobId, 'Failed to get job id')