screwdriver-api 4.1.268 → 4.1.271

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.268",
3
+ "version": "4.1.271",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -83,7 +83,7 @@
83
83
  "badge-maker": "^3.3.1",
84
84
  "config": "^1.31.0",
85
85
  "date-fns": "^1.30.1",
86
- "dayjs": "^1.10.7",
86
+ "dayjs": "^1.11.4",
87
87
  "hapi-auth-bearer-token": "^8.0.0",
88
88
  "hapi-auth-jwt2": "^10.2.0",
89
89
  "hapi-rate-limit": "^5.0.1",
@@ -104,8 +104,8 @@
104
104
  "screwdriver-command-validator": "^2.1.0",
105
105
  "screwdriver-config-parser": "^7.6.0",
106
106
  "screwdriver-coverage-bookend": "^1.0.3",
107
- "screwdriver-coverage-sonar": "^3.3.3",
108
- "screwdriver-data-schema": "^21.22.2",
107
+ "screwdriver-coverage-sonar": "^3.4.0",
108
+ "screwdriver-data-schema": "^21.26.2",
109
109
  "screwdriver-datastore-sequelize": "^7.2.7",
110
110
  "screwdriver-executor-base": "^8.4.0",
111
111
  "screwdriver-executor-docker": "^5.0.1",
@@ -114,7 +114,7 @@
114
114
  "screwdriver-executor-queue": "^3.1.2",
115
115
  "screwdriver-executor-router": "^2.3.0",
116
116
  "screwdriver-logger": "^1.1.0",
117
- "screwdriver-models": "^28.17.0",
117
+ "screwdriver-models": "^28.17.8",
118
118
  "screwdriver-notifications-email": "^2.2.0",
119
119
  "screwdriver-notifications-slack": "^3.2.1",
120
120
  "screwdriver-request": "^1.0.3",
@@ -125,7 +125,7 @@
125
125
  "screwdriver-scm-router": "^6.3.0",
126
126
  "screwdriver-template-validator": "^5.2.0",
127
127
  "screwdriver-workflow-parser": "^3.2.1",
128
- "sqlite3": "^5.0.1",
128
+ "sqlite3": "^5.0.9",
129
129
  "stream": "0.0.2",
130
130
  "tinytim": "^0.1.1",
131
131
  "uuid": "^8.3.2",
@@ -153,7 +153,7 @@
153
153
  "mocha-sonarqube-reporter": "^1.0.2",
154
154
  "mockery": "^2.0.0",
155
155
  "mz": "^2.6.0",
156
- "nock": "^13.2.7",
156
+ "nock": "^13.2.9",
157
157
  "node-plantuml": "^0.5.0",
158
158
  "npm-auto-version": "^1.0.0",
159
159
  "nyc": "^15.0.0",
@@ -114,6 +114,15 @@ Only PR events of specified PR number will be searched when `prNum` is set
114
114
 
115
115
  `GET /pipelines/{id}/triggers`
116
116
 
117
+ #### Get all stages for a single pipeline
118
+
119
+ `GET /pipelines/{id}/stages`
120
+ Will get latest commit event's stages if no event ID or group event ID is provided
121
+
122
+ `GET /pipelines/{id}/stages?groupEventId={groupEventId}`
123
+
124
+ `GET /pipelines/{id}/stages?eventId={eventId}`
125
+
117
126
  #### Get all pipeline secrets
118
127
 
119
128
  `GET /pipelines/{id}/secrets`
@@ -22,22 +22,52 @@ module.exports = () => ({
22
22
  },
23
23
 
24
24
  handler: async (request, h) => {
25
- const { pipelineFactory, stageFactory } = request.server.app;
25
+ const { pipelineFactory, stageFactory, eventFactory } = request.server.app;
26
26
  const pipelineId = request.params.id;
27
27
 
28
28
  return pipelineFactory
29
29
  .get(pipelineId)
30
- .then(pipeline => {
30
+ .then(async pipeline => {
31
31
  if (!pipeline) {
32
- throw boom.notFound('Pipeline does not exist');
32
+ throw boom.notFound(`Pipeline ${pipelineId} does not exist`);
33
33
  }
34
34
 
35
35
  const config = {
36
36
  params: { pipelineId }
37
37
  };
38
38
 
39
- if (request.query.state) {
40
- config.params.state = request.query.state;
39
+ // Set groupEventId if provided
40
+ if (request.query.groupEventId) {
41
+ config.params.groupEventId = request.query.groupEventId;
42
+ }
43
+ // Get specific stages if eventId is provided
44
+ else if (request.query.eventId) {
45
+ const events = await eventFactory.list({ params: { id: request.query.eventId } });
46
+
47
+ if (!events || Object.keys(events).length === 0) {
48
+ throw boom.notFound(`Event ${request.query.eventId} does not exist`);
49
+ }
50
+
51
+ config.params.groupEventId = events[0].groupEventId;
52
+ }
53
+ // Get latest stages if eventId not provided
54
+ else {
55
+ const latestCommitEvents = await eventFactory.list({
56
+ params: {
57
+ pipelineId,
58
+ parentEventId: null,
59
+ type: 'pipeline'
60
+ },
61
+ paginate: {
62
+ count: 1
63
+ }
64
+ });
65
+
66
+ if (!latestCommitEvents || Object.keys(latestCommitEvents).length === 0) {
67
+ throw boom.notFound(`Latest event does not exist for pipeline ${pipelineId}`);
68
+ }
69
+
70
+ config.params.groupEventId = latestCommitEvents[0].groupEventId;
41
71
  }
42
72
 
43
73
  return stageFactory.list(config);
@@ -53,7 +83,13 @@ module.exports = () => ({
53
83
  validate: {
54
84
  params: joi.object({
55
85
  id: pipelineIdSchema
56
- })
86
+ }),
87
+ query: schema.api.pagination.concat(
88
+ joi.object({
89
+ eventId: pipelineIdSchema,
90
+ groupEventId: pipelineIdSchema
91
+ })
92
+ )
57
93
  }
58
94
  }
59
95
  });