screwdriver-api 4.1.255 → 4.1.256

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "4.1.255",
3
+ "version": "4.1.256",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -288,7 +288,21 @@ async function createInternalBuild(config) {
288
288
  baseBranch
289
289
  };
290
290
 
291
- if (job.state === 'ENABLED') {
291
+ let jobState = job.state;
292
+
293
+ if (prRef) {
294
+ // Whether a job is enabled is determined by the state of the original job.
295
+ // If the original job does not exist, it will be enabled.
296
+ const originalJobName = job.parsePRJobName('job');
297
+ const originalJob = await jobFactory.get({
298
+ name: originalJobName,
299
+ pipelineId
300
+ });
301
+
302
+ jobState = originalJob ? originalJob.state : 'ENABLED';
303
+ }
304
+
305
+ if (jobState === 'ENABLED') {
292
306
  return buildFactory.create(internalBuildConfig);
293
307
  }
294
308