screwdriver-api 8.0.181 → 8.0.182
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
|
@@ -6,7 +6,7 @@ const merge = require('lodash.mergewith');
|
|
|
6
6
|
const isEmpty = require('lodash.isempty');
|
|
7
7
|
const { PR_JOB_NAME, PR_STAGE_NAME, STAGE_TEARDOWN_PATTERN } = require('screwdriver-data-schema').config.regex;
|
|
8
8
|
const { getFullStageJobName } = require('../../helper');
|
|
9
|
-
const
|
|
9
|
+
const locker = require('../../lock');
|
|
10
10
|
const { updateVirtualBuildSuccess, emitBuildStatusEvent, isFixedBuild } = require('../triggers/helpers');
|
|
11
11
|
const TERMINAL_STATUSES = ['FAILURE', 'ABORTED', 'UNSTABLE', 'COLLAPSED'];
|
|
12
12
|
const FINISHED_STATUSES = ['SUCCESS', ...TERMINAL_STATUSES];
|
|
@@ -459,8 +459,16 @@ async function updateBuildAndTriggerDownstreamJobs(config, build, server, userna
|
|
|
459
459
|
let stageBuild;
|
|
460
460
|
const isStageTeardown = STAGE_TEARDOWN_PATTERN.test(job.name);
|
|
461
461
|
let stageBuildHasFailure = false;
|
|
462
|
+
let stageLock;
|
|
463
|
+
let stageResource;
|
|
462
464
|
|
|
463
465
|
if (stage) {
|
|
466
|
+
stageResource = `event:${event.id}:stage:${stage.id}`;
|
|
467
|
+
try {
|
|
468
|
+
stageLock = await locker.lock(stageResource);
|
|
469
|
+
} catch (err) {
|
|
470
|
+
stageLock = null;
|
|
471
|
+
}
|
|
464
472
|
stageBuild = await stageBuildFactory.get({
|
|
465
473
|
stageId: stage.id,
|
|
466
474
|
eventId: newEvent.id
|
|
@@ -534,6 +542,13 @@ async function updateBuildAndTriggerDownstreamJobs(config, build, server, userna
|
|
|
534
542
|
}
|
|
535
543
|
}
|
|
536
544
|
}
|
|
545
|
+
if (stageResource) {
|
|
546
|
+
try {
|
|
547
|
+
await locker.unlock(stageLock, stageResource);
|
|
548
|
+
} catch (err) {
|
|
549
|
+
// ignore unlock errors for parity with lock helper behavior
|
|
550
|
+
}
|
|
551
|
+
}
|
|
537
552
|
|
|
538
553
|
// update event status
|
|
539
554
|
const latestBuilds = await newEvent.getBuilds();
|