screwdriver-api 8.0.70 → 8.0.72

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": "8.0.70",
3
+ "version": "8.0.72",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -230,6 +230,17 @@ const authPlugin = {
230
230
  scmContext: user.scmContext,
231
231
  scope: ['user']
232
232
  };
233
+
234
+ const scmDisplayName = scm.getDisplayName({ scmContext: profile.scmContext });
235
+ const userDisplayName = pluginOptions.authCheckById
236
+ ? `${scmDisplayName}:${profile.username}:${profile.scmUserId}`
237
+ : `${scmDisplayName}:${profile.username}`;
238
+ const admins = pluginOptions.authCheckById ? pluginOptions.sdAdmins : pluginOptions.admins;
239
+
240
+ // Check admin
241
+ if (admins.length > 0 && admins.includes(userDisplayName)) {
242
+ profile.scope.push('admin');
243
+ }
233
244
  }
234
245
  if (token.pipelineId) {
235
246
  // if token has pipelineId then the token is for pipeline
@@ -400,18 +400,19 @@ async function updateBuildAndTriggerDownstreamJobs(config, build, server, userna
400
400
  jobName: job.name,
401
401
  pipelineId: pipeline.id
402
402
  });
403
+ let stageBuild;
403
404
  const isStageTeardown = STAGE_TEARDOWN_PATTERN.test(job.name);
404
405
  let stageBuildHasFailure = false;
405
406
 
406
407
  if (stage) {
407
- const stageBuild = await stageBuildFactory.get({
408
+ stageBuild = await stageBuildFactory.get({
408
409
  stageId: stage.id,
409
410
  eventId: newEvent.id
410
411
  });
411
412
 
412
- const newStageBuild = await updateStageBuildStatus({ stageBuild, newStatus: newBuild.status, job });
413
+ stageBuild = await updateStageBuildStatus({ stageBuild, newStatus: newBuild.status, job });
413
414
 
414
- stageBuildHasFailure = TERMINAL_STATUSES.includes(newStageBuild.status);
415
+ stageBuildHasFailure = TERMINAL_STATUSES.includes(stageBuild.status);
415
416
  }
416
417
 
417
418
  // Guard against triggering non-successful or unstable builds
@@ -461,6 +462,7 @@ async function updateBuildAndTriggerDownstreamJobs(config, build, server, userna
461
462
 
462
463
  if (teardownNode && teardownNode.virtual) {
463
464
  await updateVirtualBuildSuccess(stageTeardownBuild);
465
+ await updateStageBuildStatus({ stageBuild, newStatus: 'SUCCESS', job: stageTeardownJob });
464
466
  } else {
465
467
  stageTeardownBuild.status = 'QUEUED';
466
468