screwdriver-api 7.0.258 → 7.0.260

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.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: Custom issue template
3
+ about: Describe this issue template's purpose here.
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **What happened**:
11
+
12
+ **What you expected to happen**:
13
+
14
+ **How to reproduce it**:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "7.0.258",
3
+ "version": "7.0.260",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -634,10 +634,22 @@ async function getParentBuildStatus({ newBuild, joinListNames, pipelineId, build
634
634
  * @param {String|undefined} arg.pipelineId Pipeline ID
635
635
  * @param {String|undefined} arg.stageName Stage name
636
636
  * @param {Event} arg.event Event
637
+ * @param {Build} arg.currentBuild Current build
637
638
  * @returns {Promise<Build|null>} The newly updated/created build
638
639
  */
639
- async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, stageName, event }) {
640
+ async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, stageName, event, currentBuild }) {
640
641
  if (!done || Status.isStarted(newBuild.status)) {
642
+ // The virtual job does not inherit metadata because the Launcher is not executed.
643
+ // Therefore, it is necessary to take over the metadata from the previous build.
644
+
645
+ // TODO There is a bug when virtual job requires [a, b] and if "a" and "b" are completed simultaneously.
646
+ // https://github.com/screwdriver-cd/screwdriver/issues/3287
647
+ if (isVirtualJob(job) && !hasFreezeWindows(job)) {
648
+ newBuild.meta = merge({}, newBuild.meta, currentBuild.meta);
649
+
650
+ await newBuild.update();
651
+ }
652
+
641
653
  return null;
642
654
  }
643
655
 
@@ -661,6 +673,9 @@ async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, sta
661
673
  newBuild.status = Status.SUCCESS;
662
674
  newBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
663
675
  newBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
676
+ // The virtual job does not inherit metadata because the Launcher is not executed.
677
+ // Therefore, it is necessary to take over the metadata from the previous build.
678
+ newBuild.meta = merge({}, newBuild.meta, currentBuild.meta);
664
679
 
665
680
  return newBuild.update();
666
681
  }
@@ -103,7 +103,8 @@ class JoinBase {
103
103
  job: nextJob,
104
104
  pipelineId,
105
105
  stageName: nextJobStageName,
106
- event
106
+ event,
107
+ currentBuild: this.currentBuild
107
108
  });
108
109
  }
109
110
  }
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const merge = require('lodash.mergewith');
3
4
  const { createInternalBuild, Status, BUILD_STATUS_MESSAGES, isVirtualJob, hasFreezeWindows } = require('./helpers');
4
5
 
5
6
  /**
@@ -60,6 +61,7 @@ class OrBase {
60
61
  nextBuild.status = Status.SUCCESS;
61
62
  nextBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
62
63
  nextBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
64
+ nextBuild.meta = merge({}, nextBuild.meta, this.currentBuild.meta);
63
65
 
64
66
  return nextBuild.update();
65
67
  }
@@ -91,6 +93,7 @@ class OrBase {
91
93
  nextBuild.status = Status.SUCCESS;
92
94
  nextBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
93
95
  nextBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
96
+ nextBuild.meta = merge({}, nextBuild.meta, this.currentBuild.meta);
94
97
 
95
98
  await nextBuild.update();
96
99
  }