screwdriver-api 7.0.232 → 7.0.233

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": "7.0.232",
3
+ "version": "7.0.233",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -199,31 +199,27 @@ async function triggerNextJobs(config, app) {
199
199
  }
200
200
  }
201
201
 
202
- const buildsToRestart = buildsToRestartFilter(joinedPipeline, groupEventBuilds, currentEvent, currentBuild);
203
- const isRestart = buildsToRestart.length > 0;
202
+ let isRestartPipeline = false;
203
+
204
+ if (currentEvent.parentEventId) {
205
+ const parentEvent = await eventFactory.get({ id: currentEvent.parentEventId });
206
+
207
+ isRestartPipeline = parentEvent && strToInt(currentEvent.pipelineId) === strToInt(parentEvent.pipelineId);
208
+ }
204
209
 
205
210
  // If user used external trigger syntax, the jobs are triggered as external
206
211
  if (isCurrentPipeline) {
207
212
  externalEvent = null;
208
- } else if (isRestart) {
213
+ } else if (isRestartPipeline) {
209
214
  // If parentEvent and currentEvent have the same pipelineId, then currentEvent is the event that started the restart
210
215
  // If restarted from the downstream pipeline, the remote trigger must create a new event in the upstream pipeline
211
- const parentEvent = await eventFactory.get({ id: currentEvent.parentEventId });
212
- const isRestartPipeline = strToInt(currentEvent.pipelineId) === strToInt(parentEvent.pipelineId);
213
-
214
- if (isRestartPipeline) {
215
- const sameParentEvents = await getSameParentEvents({
216
- eventFactory,
217
- parentEventId: currentEvent.id,
218
- pipelineId: strToInt(joinedPipelineId)
219
- });
216
+ const sameParentEvents = await getSameParentEvents({
217
+ eventFactory,
218
+ parentEventId: currentEvent.id,
219
+ pipelineId: strToInt(joinedPipelineId)
220
+ });
220
221
 
221
- if (sameParentEvents.length > 0) {
222
- externalEvent = sameParentEvents[0];
223
- } else {
224
- externalEvent = null;
225
- }
226
- }
222
+ externalEvent = sameParentEvents.length > 0 ? sameParentEvents[0] : null;
227
223
  }
228
224
 
229
225
  // no need to lock if there is no external event
@@ -253,6 +249,9 @@ async function triggerNextJobs(config, app) {
253
249
  groupEventId: null
254
250
  };
255
251
 
252
+ const buildsToRestart = buildsToRestartFilter(joinedPipeline, groupEventBuilds, currentEvent, currentBuild);
253
+ const isRestart = buildsToRestart.length > 0;
254
+
256
255
  // Restart case
257
256
  if (isRestart) {
258
257
  // 'joinedPipeline.event.id' is restart event, not group event.
@@ -267,9 +266,8 @@ async function triggerNextJobs(config, app) {
267
266
  pipelineId: strToInt(joinedPipelineId)
268
267
  });
269
268
 
270
- if (sameParentEvents.length > 0) {
271
- externalEventConfig.groupEventId = sameParentEvents[0].groupEventId;
272
- }
269
+ externalEventConfig.groupEventId =
270
+ sameParentEvents.length > 0 ? sameParentEvents[0].groupEventId : currentEvent.groupEventId;
273
271
  }
274
272
 
275
273
  try {
@@ -811,7 +811,7 @@ function mergeParentBuilds(parentBuilds, relatedBuilds, currentEvent, nextEvent)
811
811
 
812
812
  if (strToInt(pipelineId) !== strToInt(currentEvent.pipelineId)) {
813
813
  if (nextEvent) {
814
- if (strToInt(pipelineId) !== nextEvent.pipelineId) {
814
+ if (strToInt(pipelineId) !== strToInt(nextEvent.pipelineId)) {
815
815
  nodeName = `sd@${pipelineId}:${nodeName}`;
816
816
  }
817
817
  workflowGraph = nextEvent.workflowGraph;