screwdriver-api 7.0.219 → 7.0.221
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
package/plugins/builds/index.js
CHANGED
|
@@ -38,7 +38,8 @@ const {
|
|
|
38
38
|
trimJobName,
|
|
39
39
|
getParallelBuilds,
|
|
40
40
|
isStartFromMiddleOfCurrentStage,
|
|
41
|
-
Status
|
|
41
|
+
Status,
|
|
42
|
+
getSameParentEvents
|
|
42
43
|
} = require('./triggers/helpers');
|
|
43
44
|
const { getFullStageJobName } = require('../helper');
|
|
44
45
|
|
|
@@ -186,14 +187,43 @@ async function triggerNextJobs(config, app) {
|
|
|
186
187
|
});
|
|
187
188
|
|
|
188
189
|
groupEventBuilds.push(...parallelBuilds);
|
|
190
|
+
} else {
|
|
191
|
+
const sameParentEvents = await getSameParentEvents({
|
|
192
|
+
eventFactory,
|
|
193
|
+
parentEventId: currentEvent.id,
|
|
194
|
+
pipelineId: strToInt(joinedPipelineId)
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (sameParentEvents.length > 0) {
|
|
198
|
+
externalEvent = sameParentEvents[0];
|
|
199
|
+
}
|
|
189
200
|
}
|
|
190
201
|
|
|
191
202
|
const buildsToRestart = buildsToRestartFilter(joinedPipeline, groupEventBuilds, currentEvent, currentBuild);
|
|
192
203
|
const isRestart = buildsToRestart.length > 0;
|
|
193
204
|
|
|
194
205
|
// If user used external trigger syntax, the jobs are triggered as external
|
|
195
|
-
if (isCurrentPipeline
|
|
206
|
+
if (isCurrentPipeline) {
|
|
196
207
|
externalEvent = null;
|
|
208
|
+
} else if (isRestart) {
|
|
209
|
+
// If parentEvent and currentEvent have the same pipelineId, then currentEvent is the event that started the restart
|
|
210
|
+
// 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
|
+
});
|
|
220
|
+
|
|
221
|
+
if (sameParentEvents.length > 0) {
|
|
222
|
+
externalEvent = sameParentEvents[0];
|
|
223
|
+
} else {
|
|
224
|
+
externalEvent = null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
197
227
|
}
|
|
198
228
|
|
|
199
229
|
// no need to lock if there is no external event
|
|
@@ -225,8 +255,21 @@ async function triggerNextJobs(config, app) {
|
|
|
225
255
|
|
|
226
256
|
// Restart case
|
|
227
257
|
if (isRestart) {
|
|
228
|
-
|
|
258
|
+
// 'joinedPipeline.event.id' is restart event, not group event.
|
|
259
|
+
const groupEvent = await eventFactory.get({ id: joinedPipeline.event.id });
|
|
260
|
+
|
|
261
|
+
externalEventConfig.groupEventId = groupEvent.groupEventId;
|
|
229
262
|
externalEventConfig.parentBuilds = buildsToRestart[0].parentBuilds;
|
|
263
|
+
} else {
|
|
264
|
+
const sameParentEvents = await getSameParentEvents({
|
|
265
|
+
eventFactory,
|
|
266
|
+
parentEventId: currentEvent.groupEventId,
|
|
267
|
+
pipelineId: strToInt(joinedPipelineId)
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
if (sameParentEvents.length > 0) {
|
|
271
|
+
externalEventConfig.groupEventId = sameParentEvents[0].groupEventId;
|
|
272
|
+
}
|
|
230
273
|
}
|
|
231
274
|
|
|
232
275
|
try {
|
|
@@ -678,6 +678,24 @@ async function getParallelBuilds({ eventFactory, parentEventId, pipelineId }) {
|
|
|
678
678
|
return parallelBuilds;
|
|
679
679
|
}
|
|
680
680
|
|
|
681
|
+
/**
|
|
682
|
+
* Get all events with a given event ID and pipeline ID
|
|
683
|
+
* @param {Object} arg
|
|
684
|
+
* @param {EventFactory} eventFactory Event factory
|
|
685
|
+
* @param {Number} parentEventId Parent event ID
|
|
686
|
+
* @param {Number} pipelineId Pipeline ID
|
|
687
|
+
* @returns {Promise<Event[]>} Array of events with same parent event ID and same pipeline ID
|
|
688
|
+
*/
|
|
689
|
+
async function getSameParentEvents({ eventFactory, parentEventId, pipelineId }) {
|
|
690
|
+
const parallelEvents = await eventFactory.list({
|
|
691
|
+
params: {
|
|
692
|
+
parentEventId
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
return parallelEvents.filter(pe => strToInt(pe.pipelineId) === pipelineId);
|
|
697
|
+
}
|
|
698
|
+
|
|
681
699
|
/**
|
|
682
700
|
* Get subsequent job names which the root is the start from node
|
|
683
701
|
* @param {Array} [workflowGraph] Array of graph vertices
|
|
@@ -1148,6 +1166,7 @@ module.exports = {
|
|
|
1148
1166
|
parseJobInfo,
|
|
1149
1167
|
createInternalBuild,
|
|
1150
1168
|
getParallelBuilds,
|
|
1169
|
+
getSameParentEvents,
|
|
1151
1170
|
mergeParentBuilds,
|
|
1152
1171
|
updateParentBuilds,
|
|
1153
1172
|
getParentBuildStatus,
|