screwdriver-api 8.0.111 → 8.0.112
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
|
@@ -26,6 +26,7 @@ const removeToken = require('./tokens/remove');
|
|
|
26
26
|
const removeAllTokens = require('./tokens/removeAll');
|
|
27
27
|
const metricsRoute = require('./metrics');
|
|
28
28
|
const latestBuild = require('./latestBuild');
|
|
29
|
+
const lastSuccessfulEvent = require('./lastSuccessfulEvent');
|
|
29
30
|
const latestCommitEvent = require('./latestCommitEvent');
|
|
30
31
|
const getAdmin = require('./admins/get');
|
|
31
32
|
const listAdminsRoute = require('./admins/list');
|
|
@@ -264,6 +265,7 @@ const pipelinesPlugin = {
|
|
|
264
265
|
removeAllTokens(),
|
|
265
266
|
metricsRoute(),
|
|
266
267
|
latestBuild(),
|
|
268
|
+
lastSuccessfulEvent(),
|
|
267
269
|
latestCommitEvent(),
|
|
268
270
|
getAdmin(),
|
|
269
271
|
listAdminsRoute(),
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const boom = require('@hapi/boom');
|
|
4
|
+
const joi = require('joi');
|
|
5
|
+
const schema = require('screwdriver-data-schema');
|
|
6
|
+
const getSchema = schema.models.event.get;
|
|
7
|
+
const idSchema = schema.models.pipeline.base.extract('id');
|
|
8
|
+
|
|
9
|
+
module.exports = () => ({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/pipelines/{id}/lastSuccessfulEvent',
|
|
12
|
+
options: {
|
|
13
|
+
description: 'Get last successful event for a given pipeline',
|
|
14
|
+
notes: 'Return last successful event',
|
|
15
|
+
tags: ['api', 'pipelines'],
|
|
16
|
+
auth: {
|
|
17
|
+
strategies: ['token'],
|
|
18
|
+
scope: ['user', 'build', 'pipeline']
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
handler: async (request, h) => {
|
|
22
|
+
const { eventFactory } = request.server.app;
|
|
23
|
+
|
|
24
|
+
const successEvents = await eventFactory.list({
|
|
25
|
+
params: {
|
|
26
|
+
pipelineId: request.params.id,
|
|
27
|
+
status: 'SUCCESS',
|
|
28
|
+
type: 'pipeline'
|
|
29
|
+
},
|
|
30
|
+
sort: 'descending',
|
|
31
|
+
sortBy: 'id',
|
|
32
|
+
paginate: {
|
|
33
|
+
count: 1
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!successEvents || successEvents.length === 0) {
|
|
38
|
+
throw boom.notFound('Successful event does not exist');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return h.response(successEvents[0].toJson());
|
|
42
|
+
},
|
|
43
|
+
response: {
|
|
44
|
+
schema: getSchema
|
|
45
|
+
},
|
|
46
|
+
validate: {
|
|
47
|
+
params: joi.object({
|
|
48
|
+
id: idSchema
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|