screwdriver-api 4.1.172 → 4.1.176

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": "4.1.172",
3
+ "version": "4.1.176",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -270,6 +270,7 @@ async function createInternalBuild(config) {
270
270
  } else {
271
271
  job = await jobFactory.get(jobId);
272
272
  }
273
+
273
274
  const internalBuildConfig = {
274
275
  jobId: job.id,
275
276
  sha: event.sha,
@@ -409,11 +410,6 @@ function parseJobInfo({ joinObj = {}, current, nextJobName, nextPipelineId }) {
409
410
  * @return {Promise} All finished builds
410
411
  */
411
412
  async function getFinishedBuilds(event, buildFactory) {
412
- if (!event.parentEventId) {
413
- // FIXME: remove this flow to always use buildFactory.getLatestBuilds
414
- return event.getBuilds();
415
- }
416
-
417
413
  // FIXME: buildFactory.getLatestBuilds doesn't return build model
418
414
  const builds = await buildFactory.getLatestBuilds({ groupEventId: event.groupEventId });
419
415
 
@@ -32,6 +32,9 @@ server.register({
32
32
  #### Returns a list of builds associated with the event
33
33
  `GET /events/{id}/builds`
34
34
 
35
+ `GET /events/{id}/builds?steps=true`
36
+
37
+
35
38
  #### Get build metrics for a single event
36
39
  `GET /events/{id}/metrics`
37
40
 
@@ -24,14 +24,23 @@ module.exports = () => ({
24
24
  handler: async (request, h) => {
25
25
  const { eventFactory } = request.server.app;
26
26
  const event = await eventFactory.get(request.params.id);
27
+ const { steps } = request.query;
27
28
 
28
29
  if (!event) {
29
30
  throw boom.notFound('Event does not exist');
30
31
  }
31
32
 
32
- const buildsModel = await event.getBuilds();
33
+ const buildsModel = await event.getBuilds({
34
+ readOnly: true
35
+ });
33
36
 
34
- const data = await Promise.all(buildsModel.map(async buildModel => buildModel.toJsonWithSteps()));
37
+ let data;
38
+
39
+ if (steps) {
40
+ data = await Promise.all(buildsModel.map(async buildModel => buildModel.toJsonWithSteps()));
41
+ } else {
42
+ data = await Promise.all(buildsModel.map(async buildModel => buildModel.toJson()));
43
+ }
35
44
 
36
45
  return h.response(data);
37
46
  },
@@ -41,7 +50,16 @@ module.exports = () => ({
41
50
  validate: {
42
51
  params: joi.object({
43
52
  id: eventIdSchema
44
- })
53
+ }),
54
+ query: schema.api.pagination.concat(
55
+ joi.object({
56
+ steps: joi
57
+ .boolean()
58
+ .truthy('true')
59
+ .falsy('false')
60
+ .default(false)
61
+ })
62
+ )
45
63
  }
46
64
  }
47
65
  });
@@ -46,6 +46,8 @@ Example payload:
46
46
  #### Get list of builds for a single job
47
47
  `GET /jobs/{id}/builds`
48
48
 
49
+ `GET /jobs/{id}/builds?steps=true`
50
+
49
51
  `GET /jobs/{id}/builds?page=2&count=30&sort=ascending`
50
52
 
51
53
  `GET /jobs/{id}/builds?page=2&count=30&sort=ascending&sortBy=id`
@@ -23,7 +23,7 @@ module.exports = () => ({
23
23
 
24
24
  handler: async (request, h) => {
25
25
  const factory = request.server.app.jobFactory;
26
- const { sort, sortBy, page, count } = request.query;
26
+ const { sort, sortBy, page, count, steps } = request.query;
27
27
 
28
28
  return factory
29
29
  .get(request.params.id)
@@ -32,7 +32,7 @@ module.exports = () => ({
32
32
  throw boom.notFound('Job does not exist');
33
33
  }
34
34
 
35
- const config = { sort, sortBy: 'createTime' };
35
+ const config = { sort, sortBy: 'createTime', readOnly: true };
36
36
 
37
37
  if (sortBy) {
38
38
  config.sortBy = sortBy;
@@ -45,7 +45,13 @@ module.exports = () => ({
45
45
  return job.getBuilds(config);
46
46
  })
47
47
  .then(async builds => {
48
- const data = await Promise.all(builds.map(b => b.toJsonWithSteps()));
48
+ let data;
49
+
50
+ if (steps) {
51
+ data = await Promise.all(builds.map(b => b.toJsonWithSteps()));
52
+ } else {
53
+ data = await Promise.all(builds.map(b => b.toJson()));
54
+ }
49
55
 
50
56
  return h.response(data);
51
57
  })
@@ -60,7 +66,15 @@ module.exports = () => ({
60
66
  params: joi.object({
61
67
  id: jobIdSchema
62
68
  }),
63
- query: schema.api.pagination
69
+ query: schema.api.pagination.concat(
70
+ joi.object({
71
+ steps: joi
72
+ .boolean()
73
+ .truthy('true')
74
+ .falsy('false')
75
+ .default(false)
76
+ })
77
+ )
64
78
  }
65
79
  }
66
80
  });