screwdriver-api 7.0.217 → 7.0.219
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": "7.0.
|
|
3
|
+
"version": "7.0.219",
|
|
4
4
|
"description": "API server for the Screwdriver.cd service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"screwdriver-config-parser": "^11.0.0",
|
|
110
110
|
"screwdriver-coverage-bookend": "^2.0.0",
|
|
111
111
|
"screwdriver-coverage-sonar": "^4.1.1",
|
|
112
|
-
"screwdriver-data-schema": "^24.
|
|
112
|
+
"screwdriver-data-schema": "^24.1.0",
|
|
113
113
|
"screwdriver-datastore-sequelize": "^9.0.0",
|
|
114
114
|
"screwdriver-executor-base": "^10.0.0",
|
|
115
115
|
"screwdriver-executor-docker": "^7.0.0",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"screwdriver-executor-queue": "^5.0.0",
|
|
119
119
|
"screwdriver-executor-router": "^4.0.0",
|
|
120
120
|
"screwdriver-logger": "^2.0.0",
|
|
121
|
-
"screwdriver-models": "^30.
|
|
121
|
+
"screwdriver-models": "^30.2.0",
|
|
122
122
|
"screwdriver-notifications-email": "^4.0.0",
|
|
123
123
|
"screwdriver-notifications-slack": "^6.0.0",
|
|
124
124
|
"screwdriver-request": "^2.0.1",
|
package/plugins/builds/README.md
CHANGED
|
@@ -75,12 +75,11 @@ Example payload:
|
|
|
75
75
|
Arguments:
|
|
76
76
|
|
|
77
77
|
* `type` - Return type for build artifact, `download` or `preview`
|
|
78
|
+
* `dir` - If downloading directory or not (`true` or `false`, default `false`). Must be set with `type=download`.
|
|
78
79
|
|
|
79
80
|
`GET /builds/{id}/artifacts/{name*}?type=preview`
|
|
80
81
|
|
|
81
|
-
`GET /builds/{id}/artifacts/this/is/a/directory/path
|
|
82
|
-
|
|
83
|
-
*Note: To download a directory, there must be a trailing slash (`/`) in the name and `type=download`.*
|
|
82
|
+
`GET /builds/{id}/artifacts/this/is/a/directory/path?type=download&dir=true`
|
|
84
83
|
|
|
85
84
|
#### Get build statuses
|
|
86
85
|
`GET /builds/statuses`
|
|
@@ -50,9 +50,9 @@ module.exports = config => ({
|
|
|
50
50
|
.then(async () => {
|
|
51
51
|
// Directory should fetch manifest and
|
|
52
52
|
// gather all files that belong to that directory
|
|
53
|
-
if (
|
|
53
|
+
if (req.query.dir && req.query.type === 'download') {
|
|
54
54
|
// Create a zip name from the directory structure
|
|
55
|
-
const zipName = artifact.split('/').slice(-
|
|
55
|
+
const zipName = artifact.split('/').slice(-1)[0];
|
|
56
56
|
|
|
57
57
|
try {
|
|
58
58
|
const token = jwt.sign({
|
|
@@ -69,7 +69,7 @@ module.exports = config => ({
|
|
|
69
69
|
method: 'GET'
|
|
70
70
|
}).text();
|
|
71
71
|
const manifestArray = manifest.trim().split('\n');
|
|
72
|
-
const directoryArray = manifestArray.filter(f => f.startsWith(`./${artifact}
|
|
72
|
+
const directoryArray = manifestArray.filter(f => f.startsWith(`./${artifact}/`));
|
|
73
73
|
|
|
74
74
|
// Create a stream and set up archiver
|
|
75
75
|
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
@@ -100,7 +100,7 @@ module.exports = config => ({
|
|
|
100
100
|
archive.emit('error', err); // Emit error to stop the archive process
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
const relativePath = file.replace(`./${artifact}
|
|
103
|
+
const relativePath = file.replace(`./${artifact}/`, `./${zipName}/`);
|
|
104
104
|
|
|
105
105
|
// Append the file stream to the archive with the correct relative path
|
|
106
106
|
archive.append(fileStream, { name: relativePath });
|
|
@@ -168,7 +168,8 @@ module.exports = config => ({
|
|
|
168
168
|
name: artifactSchema
|
|
169
169
|
}),
|
|
170
170
|
query: joi.object({
|
|
171
|
-
type: typeSchema
|
|
171
|
+
type: typeSchema,
|
|
172
|
+
dir: joi.boolean().truthy('true').falsy('false').default(false)
|
|
172
173
|
}).options({ allowUnknown: true })
|
|
173
174
|
}
|
|
174
175
|
}
|
|
@@ -6,6 +6,12 @@ const merge = require('lodash.mergewith');
|
|
|
6
6
|
const schema = require('screwdriver-data-schema');
|
|
7
7
|
const { EXTERNAL_TRIGGER_ALL, STAGE_SETUP_PATTERN } = schema.config.regex;
|
|
8
8
|
const { getFullStageJobName } = require('../../helper');
|
|
9
|
+
const BUILD_STATUS_MESSAGES = {
|
|
10
|
+
SKIP_VIRTUAL_JOB: {
|
|
11
|
+
statusMessage: 'Skipped execution of the virtual job',
|
|
12
|
+
statusMessageType: 'INFO'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* @typedef {import('screwdriver-models').JobFactory} JobFactory
|
|
@@ -630,6 +636,8 @@ async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, sta
|
|
|
630
636
|
|
|
631
637
|
if (isVirtualJob && !hasFreezeWindows) {
|
|
632
638
|
newBuild.status = Status.SUCCESS;
|
|
639
|
+
newBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
|
|
640
|
+
newBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
|
|
633
641
|
|
|
634
642
|
return newBuild.update();
|
|
635
643
|
}
|
|
@@ -1158,5 +1166,6 @@ module.exports = {
|
|
|
1158
1166
|
extractExternalJoinData,
|
|
1159
1167
|
buildsToRestartFilter,
|
|
1160
1168
|
trimJobName,
|
|
1161
|
-
isStartFromMiddleOfCurrentStage
|
|
1169
|
+
isStartFromMiddleOfCurrentStage,
|
|
1170
|
+
BUILD_STATUS_MESSAGES
|
|
1162
1171
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { createInternalBuild, Status } = require('./helpers');
|
|
3
|
+
const { createInternalBuild, Status, BUILD_STATUS_MESSAGES } = require('./helpers');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {import('screwdriver-models').BuildFactory} BuildFactory
|
|
@@ -58,6 +58,8 @@ class OrBase {
|
|
|
58
58
|
// Bypass execution of the build if the job is virtual
|
|
59
59
|
if (isNextJobVirtual && !hasFreezeWindows) {
|
|
60
60
|
nextBuild.status = Status.SUCCESS;
|
|
61
|
+
nextBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
|
|
62
|
+
nextBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
|
|
61
63
|
|
|
62
64
|
return nextBuild.update();
|
|
63
65
|
}
|
|
@@ -86,6 +88,8 @@ class OrBase {
|
|
|
86
88
|
// Bypass execution of the build if the job is virtual
|
|
87
89
|
if (isNextJobVirtual && !hasFreezeWindows) {
|
|
88
90
|
nextBuild.status = Status.SUCCESS;
|
|
91
|
+
nextBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
|
|
92
|
+
nextBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
|
|
89
93
|
|
|
90
94
|
nextBuild = nextBuild.update();
|
|
91
95
|
}
|
package/plugins/builds/update.js
CHANGED
|
@@ -129,12 +129,13 @@ async function validateUserPermission(build, request) {
|
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* Set build status to desired status, set build statusMessage
|
|
132
|
-
* @param {Object} build
|
|
133
|
-
* @param {String} desiredStatus
|
|
134
|
-
* @param {String} statusMessage
|
|
135
|
-
* @param {String}
|
|
132
|
+
* @param {Object} build Build Model
|
|
133
|
+
* @param {String} desiredStatus New Status
|
|
134
|
+
* @param {String} statusMessage User passed status message
|
|
135
|
+
* @param {String} statusMessageType User passed severity of the status message
|
|
136
|
+
* @param {String} username User initiating status build update
|
|
136
137
|
*/
|
|
137
|
-
function updateBuildStatus(build, desiredStatus, statusMessage, username) {
|
|
138
|
+
function updateBuildStatus(build, desiredStatus, statusMessage, statusMessageType, username) {
|
|
138
139
|
// UNSTABLE -> SUCCESS needs to update meta and endtime.
|
|
139
140
|
// However, the status itself cannot be updated to SUCCESS
|
|
140
141
|
const currentStatus = build.status;
|
|
@@ -152,9 +153,11 @@ function updateBuildStatus(build, desiredStatus, statusMessage, username) {
|
|
|
152
153
|
} else if (build.status === 'FAILURE' || build.status === 'SUCCESS') {
|
|
153
154
|
if (statusMessage) {
|
|
154
155
|
build.statusMessage = statusMessage;
|
|
156
|
+
build.statusMessageType = statusMessageType || null;
|
|
155
157
|
}
|
|
156
158
|
} else {
|
|
157
159
|
build.statusMessage = statusMessage || null;
|
|
160
|
+
build.statusMessageType = statusMessageType || null;
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
163
|
}
|
|
@@ -219,7 +222,7 @@ module.exports = () => ({
|
|
|
219
222
|
handler: async (request, h) => {
|
|
220
223
|
const { buildFactory, eventFactory, jobFactory, stageFactory, stageBuildFactory } = request.server.app;
|
|
221
224
|
const { id } = request.params;
|
|
222
|
-
const { statusMessage, stats, status: desiredStatus } = request.payload;
|
|
225
|
+
const { statusMessage, statusMessageType, stats, status: desiredStatus } = request.payload;
|
|
223
226
|
const { username, scmContext, scope } = request.auth.credentials;
|
|
224
227
|
const isBuild = scope.includes('build') || scope.includes('temporal');
|
|
225
228
|
const { triggerNextJobs, removeJoinBuilds, createOrUpdateStageTeardownBuild } =
|
|
@@ -246,6 +249,7 @@ module.exports = () => ({
|
|
|
246
249
|
// Short circuit for cases that don't need to update status
|
|
247
250
|
if (!desiredStatus) {
|
|
248
251
|
build.statusMessage = statusMessage || build.statusMessage;
|
|
252
|
+
build.statusMessageType = statusMessageType || build.statusMessageType;
|
|
249
253
|
} else if (['SUCCESS', 'FAILURE', 'ABORTED'].includes(desiredStatus)) {
|
|
250
254
|
build.meta = request.payload.meta || {};
|
|
251
255
|
event.meta = merge({}, event.meta, build.meta);
|
|
@@ -266,7 +270,7 @@ module.exports = () => ({
|
|
|
266
270
|
let isFixed = Promise.resolve(false);
|
|
267
271
|
let stopFrozen = null;
|
|
268
272
|
|
|
269
|
-
updateBuildStatus(build, desiredStatus, statusMessage, username);
|
|
273
|
+
updateBuildStatus(build, desiredStatus, statusMessage, statusMessageType, username);
|
|
270
274
|
|
|
271
275
|
// If status got updated to RUNNING or COLLAPSED, update init endTime and code
|
|
272
276
|
if (['RUNNING', 'COLLAPSED', 'FROZEN'].includes(desiredStatus)) {
|