screwdriver-api 8.0.32 → 8.0.34

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.32",
3
+ "version": "8.0.34",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -137,13 +137,29 @@ async function getStage({ stageFactory, workflowGraph, jobName, pipelineId }) {
137
137
  /**
138
138
  * Get all builds in stage
139
139
  *
140
- * @param {Stage} stage Stage
141
- * @param {Event} event Event
142
- * @return {Promise<Build[]>} Builds in stage
140
+ * @param {Stage} stage Stage
141
+ * @param {Event} event Event
142
+ * @param {JobFactory} jobFactory Job Factory instance
143
+ * @return {Promise<Build[]>} Builds in stage
143
144
  */
144
- async function getStageJobBuilds({ stage, event }) {
145
+ async function getStageJobBuilds({ stage, event, jobFactory }) {
145
146
  // Get all jobIds for jobs in the stage
146
- const stageJobIds = [...stage.jobIds, stage.setup];
147
+ const stageNodes = event.workflowGraph.nodes.filter(n => {
148
+ const jobName = n.name.split(':')[1];
149
+
150
+ return n.stageName === stage.name && jobName !== 'teardown';
151
+ });
152
+ const stageJobIds = await Promise.all(
153
+ stageNodes.map(async n => {
154
+ if (n.id) {
155
+ return n.id;
156
+ }
157
+
158
+ const job = await jobFactory.get({ pipelineId: event.pipelineId, name: n.name });
159
+
160
+ return job.id;
161
+ })
162
+ );
147
163
 
148
164
  // Get all builds in a stage for this event
149
165
  return event.getBuilds({ params: { jobId: stageJobIds } });
@@ -350,7 +366,7 @@ async function updateBuildAndTriggerDownstreamJobs(config, build, server, userna
350
366
 
351
367
  // Start stage teardown build if stage is done
352
368
  if (stageTeardownBuild && stageTeardownBuild.status === 'CREATED') {
353
- const stageJobBuilds = await getStageJobBuilds({ stage, event: newEvent });
369
+ const stageJobBuilds = await getStageJobBuilds({ stage, event: newEvent, jobFactory });
354
370
  const stageIsDone = isStageDone(stageJobBuilds);
355
371
 
356
372
  if (stageIsDone) {