screwdriver-api 4.1.255 → 4.1.258

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/README.md CHANGED
@@ -52,14 +52,14 @@ Three (3) options for executor:
52
52
  - Nomad (`nomad`)
53
53
 
54
54
  Three (3) options for SCM:
55
- - Github (`github`)
56
- - Gitlab (`gitlab`)
55
+ - GitHub (`github`)
56
+ - GitLab (`gitlab`)
57
57
  - Bitbucket (`bitbucket`)
58
58
 
59
59
  ### Prerequisites
60
60
  To use Screwdriver, you will need the following prerequisites:
61
61
 
62
- - Node v8.0.0 or higher
62
+ - Node v12.0.0 or higher
63
63
  - [Kubernetes][kubectl] or [Docker][docker]
64
64
 
65
65
  ### From Source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "4.1.255",
3
+ "version": "4.1.258",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -79,7 +79,7 @@
79
79
  "@hapi/inert": "^6.0.4",
80
80
  "@hapi/vision": "^6.1.0",
81
81
  "@promster/hapi": "^6.1.0",
82
- "async": "^3.2.2",
82
+ "async": "^3.2.4",
83
83
  "badge-maker": "^3.3.1",
84
84
  "config": "^1.31.0",
85
85
  "date-fns": "^1.30.1",
@@ -87,7 +87,7 @@
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",
90
- "hapi-swagger": "^14.2.4",
90
+ "hapi-swagger": "^14.5.4",
91
91
  "ioredis": "^4.28.0",
92
92
  "joi": "^17.4.2",
93
93
  "js-yaml": "^3.14.1",
@@ -114,14 +114,14 @@
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.11.0",
117
+ "screwdriver-models": "^28.16.1",
118
118
  "screwdriver-notifications-email": "^2.2.0",
119
119
  "screwdriver-notifications-slack": "^3.2.1",
120
120
  "screwdriver-request": "^1.0.3",
121
121
  "screwdriver-scm-base": "^7.3.0",
122
122
  "screwdriver-scm-bitbucket": "^4.5.1",
123
- "screwdriver-scm-github": "^11.6.3",
124
- "screwdriver-scm-gitlab": "^2.7.2",
123
+ "screwdriver-scm-github": "^11.10.0",
124
+ "screwdriver-scm-gitlab": "^2.10.0",
125
125
  "screwdriver-scm-router": "^6.3.0",
126
126
  "screwdriver-template-validator": "^5.2.0",
127
127
  "screwdriver-workflow-parser": "^3.2.1",
@@ -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.1",
156
+ "nock": "^13.2.7",
157
157
  "node-plantuml": "^0.5.0",
158
158
  "npm-auto-version": "^1.0.0",
159
159
  "nyc": "^15.0.0",
@@ -288,7 +288,21 @@ async function createInternalBuild(config) {
288
288
  baseBranch
289
289
  };
290
290
 
291
- if (job.state === 'ENABLED') {
291
+ let jobState = job.state;
292
+
293
+ if (prRef) {
294
+ // Whether a job is enabled is determined by the state of the original job.
295
+ // If the original job does not exist, it will be enabled.
296
+ const originalJobName = job.parsePRJobName('job');
297
+ const originalJob = await jobFactory.get({
298
+ name: originalJobName,
299
+ pipelineId
300
+ });
301
+
302
+ jobState = originalJob ? originalJob.state : 'ENABLED';
303
+ }
304
+
305
+ if (jobState === 'ENABLED') {
292
306
  return buildFactory.create(internalBuildConfig);
293
307
  }
294
308
 
@@ -12,6 +12,7 @@ const listRoute = require('./list');
12
12
  const badgeRoute = require('./badge');
13
13
  const jobBadgeRoute = require('./jobBadge');
14
14
  const listJobsRoute = require('./listJobs');
15
+ const listStagesRoute = require('./listStages');
15
16
  const listTriggersRoute = require('./listTriggers');
16
17
  const listSecretsRoute = require('./listSecrets');
17
18
  const listEventsRoute = require('./listEvents');
@@ -177,6 +178,7 @@ const pipelinesPlugin = {
177
178
  badgeRoute({ statusColor }),
178
179
  jobBadgeRoute({ statusColor }),
179
180
  listJobsRoute(),
181
+ listStagesRoute(),
180
182
  listTriggersRoute(),
181
183
  listSecretsRoute(),
182
184
  listEventsRoute(),
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ const boom = require('@hapi/boom');
4
+ const joi = require('joi');
5
+ const schema = require('screwdriver-data-schema');
6
+ const pipelineIdSchema = schema.models.pipeline.base.extract('id');
7
+ const stageListSchema = joi
8
+ .array()
9
+ .items(schema.models.stage.base)
10
+ .label('List of stages');
11
+
12
+ module.exports = () => ({
13
+ method: 'GET',
14
+ path: '/pipelines/{id}/stages',
15
+ options: {
16
+ description: 'Get all stages for a given pipeline',
17
+ notes: 'Returns all stages for a given pipeline',
18
+ tags: ['api', 'pipelines', 'stages'],
19
+ auth: {
20
+ strategies: ['token'],
21
+ scope: ['user', 'build', 'pipeline']
22
+ },
23
+
24
+ handler: async (request, h) => {
25
+ const { pipelineFactory, stageFactory } = request.server.app;
26
+ const pipelineId = request.params.id;
27
+
28
+ return pipelineFactory
29
+ .get(pipelineId)
30
+ .then(pipeline => {
31
+ if (!pipeline) {
32
+ throw boom.notFound('Pipeline does not exist');
33
+ }
34
+
35
+ const config = {
36
+ params: { pipelineId }
37
+ };
38
+
39
+ if (request.query.state) {
40
+ config.params.state = request.query.state;
41
+ }
42
+
43
+ return stageFactory.list(config);
44
+ })
45
+ .then(stages => h.response(stages.map(s => s.toJson())))
46
+ .catch(err => {
47
+ throw err;
48
+ });
49
+ },
50
+ response: {
51
+ schema: stageListSchema
52
+ },
53
+ validate: {
54
+ params: joi.object({
55
+ id: pipelineIdSchema
56
+ })
57
+ }
58
+ }
59
+ });
@@ -20,9 +20,9 @@ module.exports = () => ({
20
20
  method: 'GET',
21
21
  path: '/pipelines/{id}/triggers',
22
22
  options: {
23
- description: 'Get all jobs for a given pipeline',
24
- notes: 'Returns all jobs for a given pipeline',
25
- tags: ['api', 'pipelines', 'jobs'],
23
+ description: 'Get all triggers for a given pipeline',
24
+ notes: 'Returns all triggers for a given pipeline',
25
+ tags: ['api', 'pipelines', 'triggers'],
26
26
  auth: {
27
27
  strategies: ['token'],
28
28
  scope: ['user', 'build', 'pipeline']