screwdriver-api 8.0.85 → 8.0.87
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.
|
|
3
|
+
"version": "8.0.87",
|
|
4
4
|
"description": "API server for the Screwdriver.cd service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
"badge-maker": "^3.3.1",
|
|
91
91
|
"config": "^3.3.8",
|
|
92
92
|
"dayjs": "^1.11.7",
|
|
93
|
+
"get-intrinsic": "1.3.0",
|
|
93
94
|
"got": "^11.8.3",
|
|
94
95
|
"hapi-auth-bearer-token": "^8.0.0",
|
|
95
96
|
"hapi-auth-jwt2": "^10.4.0",
|
package/plugins/builds/index.js
CHANGED
|
@@ -198,8 +198,7 @@ async function triggerNextJobs(config, server) {
|
|
|
198
198
|
let externalEvent = joinedPipeline.event;
|
|
199
199
|
|
|
200
200
|
// This includes CREATED builds too
|
|
201
|
-
const groupEventBuilds =
|
|
202
|
-
externalEvent !== undefined ? await getBuildsForGroupEvent(externalEvent.groupEventId, buildFactory) : [];
|
|
201
|
+
const groupEventBuilds = await getBuildsForGroupEvent(currentEvent.groupEventId, buildFactory);
|
|
203
202
|
|
|
204
203
|
// fetch builds created due to trigger
|
|
205
204
|
if (externalEvent) {
|
|
@@ -269,7 +268,7 @@ async function triggerNextJobs(config, server) {
|
|
|
269
268
|
parentEventId: currentEvent.id,
|
|
270
269
|
startFrom: remoteTriggerName,
|
|
271
270
|
skipMessage: 'Skip bulk external builds creation', // Don't start builds in eventFactory.
|
|
272
|
-
groupEventId:
|
|
271
|
+
groupEventId: currentEvent.groupEventId // groupEventId is the id of the first triggered event (use the upstream pipeline's in the downstream pipeline)
|
|
273
272
|
};
|
|
274
273
|
|
|
275
274
|
const buildsToRestart = buildsToRestartFilter(joinedPipeline, groupEventBuilds, currentEvent, currentBuild);
|
|
@@ -277,20 +276,7 @@ async function triggerNextJobs(config, server) {
|
|
|
277
276
|
|
|
278
277
|
// Restart case
|
|
279
278
|
if (isRestart) {
|
|
280
|
-
// 'joinedPipeline.event.id' is restart event, not group event.
|
|
281
|
-
const groupEvent = await eventFactory.get({ id: joinedPipeline.event.id });
|
|
282
|
-
|
|
283
|
-
externalEventConfig.groupEventId = groupEvent.groupEventId;
|
|
284
279
|
externalEventConfig.parentBuilds = buildsToRestart[0].parentBuilds;
|
|
285
|
-
} else {
|
|
286
|
-
const sameParentEvents = await getSameParentEvents({
|
|
287
|
-
eventFactory,
|
|
288
|
-
parentEventId: currentEvent.groupEventId,
|
|
289
|
-
pipelineId: strToInt(joinedPipelineId)
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
externalEventConfig.groupEventId =
|
|
293
|
-
sameParentEvents.length > 0 ? sameParentEvents[0].groupEventId : currentEvent.groupEventId;
|
|
294
280
|
}
|
|
295
281
|
|
|
296
282
|
try {
|
|
@@ -167,6 +167,30 @@ function getExternalEvent(currentBuild, pipelineId, eventFactory) {
|
|
|
167
167
|
return eventFactory.get(eventId);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Helper function to fetch external workflow belonging to group evnets
|
|
172
|
+
* @param {Event} currentEvent Event for current completed job
|
|
173
|
+
* @param {String} pipelineId Pipeline ID for next job to be triggered.
|
|
174
|
+
* @param {EventFactory} eventFactory Factory for querying event data store.
|
|
175
|
+
* @returns {Promise<Object>} Workflow graph of next job's pipeline
|
|
176
|
+
*/
|
|
177
|
+
async function getExternalWorkflowGraph(currentEvent, pipelineId, eventFactory) {
|
|
178
|
+
const groupExternalEvents = await eventFactory.list({
|
|
179
|
+
params: {
|
|
180
|
+
groupEventId: currentEvent.groupEventId,
|
|
181
|
+
pipelineId
|
|
182
|
+
},
|
|
183
|
+
sortBy: 'id',
|
|
184
|
+
sort: 'descending'
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (groupExternalEvents.length === 0) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return groupExternalEvents[0].workflowGraph;
|
|
192
|
+
}
|
|
193
|
+
|
|
170
194
|
/**
|
|
171
195
|
* Create event for downstream pipeline that need to be rebuilt
|
|
172
196
|
* @param {Object} config Configuration object
|
|
@@ -1004,10 +1028,15 @@ async function createJoinObject(nextJobNames, current, eventFactory) {
|
|
|
1004
1028
|
jobs = [];
|
|
1005
1029
|
|
|
1006
1030
|
const externalEvent = pipelineObj.event || (await getExternalEvent(build, nextJobPipelineId, eventFactory));
|
|
1031
|
+
const externalWorkflowGraph = externalEvent
|
|
1032
|
+
? externalEvent.workflowGraph
|
|
1033
|
+
: await getExternalWorkflowGraph(event, nextJobPipelineId, eventFactory);
|
|
1007
1034
|
|
|
1008
1035
|
if (externalEvent) {
|
|
1009
1036
|
pipelineObj.event = externalEvent;
|
|
1010
|
-
|
|
1037
|
+
}
|
|
1038
|
+
if (externalWorkflowGraph) {
|
|
1039
|
+
jobs = workflowParser.getSrcForJoin(externalWorkflowGraph, { jobName: nextJobName });
|
|
1011
1040
|
}
|
|
1012
1041
|
} else {
|
|
1013
1042
|
jobs = workflowParser.getSrcForJoin(event.workflowGraph, { jobName });
|
|
@@ -77,15 +77,7 @@ const webhooksPlugin = {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const data = Buffer.concat(chunks).toString();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
parsedPayload = JSON.parse(data);
|
|
84
|
-
} catch (err) {
|
|
85
|
-
throw boom.badData('Cannot parse payload');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const parsed = await scm.parseHook(request.headers, parsedPayload);
|
|
80
|
+
const parsed = await scm.parseHook(request.headers, data);
|
|
89
81
|
|
|
90
82
|
if (!parsed) {
|
|
91
83
|
// for all non-matching events or actions
|