diff --git a/index.js b/index.js index d14d413..0606a01 100644 --- a/index.js +++ b/index.js @@ -415,6 +415,8 @@ class ExecutorQueue extends Executor { * @param {String} config.apiUri Screwdriver's API * @param {String} config.jobId JobID that this build belongs to * @param {String} config.jobName Name of job that this build belongs to + * @param {String} config.jobState ENABLED/DISABLED + * @param {String} config.jobArchived Boolean value of whether job is archived * @param {String} config.buildId Unique ID for a build * @param {Object} config.pipeline Pipeline of the job * @param {Fn} config.tokenGen Function to generate JWT from username, scope and scmContext @@ -424,7 +426,9 @@ class ExecutorQueue extends Executor { */ async _start(config) { await this.connect(); - const { build, buildId, jobId, blockedBy, freezeWindows, token, apiUri } = config; + const { + build, buildId, jobId, jobState, jobArchived, blockedBy, freezeWindows, token, apiUri + } = config; if (!this.tokenGen) { this.tokenGen = config.tokenGen; @@ -437,6 +441,12 @@ class ExecutorQueue extends Executor { jobId }); + // Skip if job is disabled or archived + // Check if jobState & jobArchived exist first, for backward compatibility, TODO: remove later + if ((jobState && jobState !== 'ENABLED') || (jobArchived && jobArchived === true)) { + return Promise.resolve(); + } + const currentTime = new Date(); const origTime = new Date(currentTime.getTime()); diff --git a/test/data/fullConfig.json b/test/data/fullConfig.json index 58bbcf8..24b70b9 100644 --- a/test/data/fullConfig.json +++ b/test/data/fullConfig.json @@ -4,6 +4,8 @@ }, "jobId": 777, "jobName": "main", + "jobState": "ENABLED", + "jobArchived": false, "buildId": 8609, "container": "node:4", "apiUri": "http://api.com",