screwdriver-api 8.0.15 → 8.0.17
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/config/custom-environment-variables.yaml +3 -0
- package/config/default.yaml +3 -0
- package/lib/server.js +12 -3
- package/package.json +1 -1
- package/plugins/builds/create.js +15 -1
- package/plugins/events/create.js +2 -2
- package/plugins/events/index.js +16 -2
- package/plugins/events/stopBuilds.js +1 -1
- package/plugins/pipelines/sync.js +9 -0
- package/plugins/webhooks/helper.js +12 -0
package/config/default.yaml
CHANGED
|
@@ -385,6 +385,9 @@ log:
|
|
|
385
385
|
enabled: false
|
|
386
386
|
# add target scope tokens(pipeline, build, temporal, admin, guest, user)
|
|
387
387
|
scope: []
|
|
388
|
+
payload:
|
|
389
|
+
# set true to enable payload logs for all API calls over 5s
|
|
390
|
+
enabled: true
|
|
388
391
|
|
|
389
392
|
# default cluster environment variables to inject into builds
|
|
390
393
|
build:
|
package/lib/server.js
CHANGED
|
@@ -15,7 +15,7 @@ process.on('unhandledRejection', (reason, p) => {
|
|
|
15
15
|
*/
|
|
16
16
|
function handlePreResponseLogs(request, h) {
|
|
17
17
|
const { response } = request;
|
|
18
|
-
const { release } = request.server.app;
|
|
18
|
+
const { release, log } = request.server.app;
|
|
19
19
|
|
|
20
20
|
if (release && release.cookieName && request.state && !request.state[release.cookieName]) {
|
|
21
21
|
h.state(release.cookieName, release.cookieValue);
|
|
@@ -49,7 +49,15 @@ function handlePreResponseLogs(request, h) {
|
|
|
49
49
|
|
|
50
50
|
// Log request payload when it takes longer than 5 seconds to respond
|
|
51
51
|
// This is to prevent logging payloads for every request
|
|
52
|
-
if (
|
|
52
|
+
if (
|
|
53
|
+
log &&
|
|
54
|
+
log.payload &&
|
|
55
|
+
log.payload.enabled &&
|
|
56
|
+
request.info &&
|
|
57
|
+
request.info.received &&
|
|
58
|
+
Date.now() - request.info.received > 5000 &&
|
|
59
|
+
request.payload
|
|
60
|
+
) {
|
|
53
61
|
request.log(['payload'], {
|
|
54
62
|
method: request.method,
|
|
55
63
|
path: request.path,
|
|
@@ -161,7 +169,8 @@ module.exports = async config => {
|
|
|
161
169
|
ecosystem: config.ecosystem,
|
|
162
170
|
release: config.release,
|
|
163
171
|
queueWebhook: config.queueWebhook,
|
|
164
|
-
unzipArtifacts: config.unzipArtifactsEnabled
|
|
172
|
+
unzipArtifacts: config.unzipArtifactsEnabled,
|
|
173
|
+
log: config.log
|
|
165
174
|
};
|
|
166
175
|
|
|
167
176
|
const bellConfigs = await config.auth.scm.getBellConfiguration();
|
package/package.json
CHANGED
package/plugins/builds/create.js
CHANGED
|
@@ -64,8 +64,13 @@ module.exports = () => ({
|
|
|
64
64
|
const newAdmins = pipeline.admins;
|
|
65
65
|
|
|
66
66
|
delete newAdmins[username];
|
|
67
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(
|
|
68
|
+
adminUserId => adminUserId !== user.id
|
|
69
|
+
);
|
|
70
|
+
|
|
67
71
|
// This is needed to make admins dirty and update db
|
|
68
72
|
pipeline.admins = newAdmins;
|
|
73
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
69
74
|
|
|
70
75
|
return pipeline.update().then(() => {
|
|
71
76
|
throw boom.forbidden(
|
|
@@ -83,9 +88,18 @@ module.exports = () => ({
|
|
|
83
88
|
newAdmins[username] = true;
|
|
84
89
|
// This is needed to make admins dirty and update db
|
|
85
90
|
pipeline.admins = newAdmins;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const newAdminUserIds = pipeline.adminUserIds;
|
|
86
94
|
|
|
87
|
-
|
|
95
|
+
if (!newAdminUserIds.includes(user.id)) {
|
|
96
|
+
newAdminUserIds.push(user.id);
|
|
97
|
+
|
|
98
|
+
// This is needed to make admins dirty and update db
|
|
99
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
88
100
|
}
|
|
101
|
+
|
|
102
|
+
return pipeline.update();
|
|
89
103
|
})
|
|
90
104
|
// user has good permissions, sync and create a build
|
|
91
105
|
.then(() => (job.isPR() ? pipeline.syncPR(job.prNum) : pipeline.sync()))
|
package/plugins/events/create.js
CHANGED
|
@@ -152,7 +152,7 @@ module.exports = () => ({
|
|
|
152
152
|
|
|
153
153
|
// Update admins
|
|
154
154
|
if (!prNum) {
|
|
155
|
-
await updateAdmins({ permissions, pipeline,
|
|
155
|
+
await updateAdmins({ permissions, pipeline, user });
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// Get scmConfig
|
|
@@ -201,7 +201,7 @@ module.exports = () => ({
|
|
|
201
201
|
await updateAdmins({
|
|
202
202
|
permissions,
|
|
203
203
|
pipeline,
|
|
204
|
-
|
|
204
|
+
user
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
}
|
package/plugins/events/index.js
CHANGED
|
@@ -23,17 +23,22 @@ const eventsPlugin = {
|
|
|
23
23
|
* @method updateAdmins
|
|
24
24
|
* @param {Object} permissions User permissions
|
|
25
25
|
* @param {Pipeline} pipeline Pipeline object to update
|
|
26
|
-
* @param {String}
|
|
26
|
+
* @param {String} user User object
|
|
27
27
|
* @return {Promise} Updates the pipeline admins and throws an error if not an admin
|
|
28
28
|
*/
|
|
29
|
-
server.expose('updateAdmins', ({ permissions, pipeline,
|
|
29
|
+
server.expose('updateAdmins', ({ permissions, pipeline, user }) => {
|
|
30
|
+
const { username, id: userId } = user;
|
|
31
|
+
|
|
30
32
|
// Delete user from admin list if bad permissions
|
|
31
33
|
if (!permissions.push) {
|
|
32
34
|
const newAdmins = pipeline.admins;
|
|
33
35
|
|
|
34
36
|
delete newAdmins[username];
|
|
37
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(adminUserId => adminUserId !== userId);
|
|
38
|
+
|
|
35
39
|
// This is needed to make admins dirty and update db
|
|
36
40
|
pipeline.admins = newAdmins;
|
|
41
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
37
42
|
|
|
38
43
|
return pipeline.update().then(() => {
|
|
39
44
|
throw boom.forbidden(`User ${username} does not have push permission for this repo`);
|
|
@@ -49,7 +54,16 @@ const eventsPlugin = {
|
|
|
49
54
|
newAdmins[name] = true;
|
|
50
55
|
});
|
|
51
56
|
|
|
57
|
+
const newAdminUserIds = [userId];
|
|
58
|
+
|
|
59
|
+
pipeline.adminUserIds.forEach(adminUserId => {
|
|
60
|
+
if (adminUserId !== userId) {
|
|
61
|
+
newAdminUserIds.push(adminUserId);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
52
65
|
pipeline.admins = newAdmins;
|
|
66
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
53
67
|
|
|
54
68
|
return pipeline.update();
|
|
55
69
|
});
|
|
@@ -60,8 +60,11 @@ module.exports = () => ({
|
|
|
60
60
|
const newAdmins = pipeline.admins;
|
|
61
61
|
|
|
62
62
|
delete newAdmins[username];
|
|
63
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(adminUserId => adminUserId !== user.id);
|
|
64
|
+
|
|
63
65
|
// This is needed to make admins dirty and update db
|
|
64
66
|
pipeline.admins = newAdmins;
|
|
67
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
65
68
|
|
|
66
69
|
await pipeline.update();
|
|
67
70
|
|
|
@@ -77,10 +80,16 @@ module.exports = () => ({
|
|
|
77
80
|
// user has good permissions, add the user as an admin
|
|
78
81
|
if (!pipeline.admins[username] && hasPushPermissions) {
|
|
79
82
|
const newAdmins = pipeline.admins;
|
|
83
|
+
const newAdminUserIds = pipeline.adminUserIds;
|
|
80
84
|
|
|
81
85
|
newAdmins[username] = true;
|
|
86
|
+
if (!newAdminUserIds.includes(user.id)) {
|
|
87
|
+
newAdminUserIds.push(user.id);
|
|
88
|
+
}
|
|
89
|
+
|
|
82
90
|
// This is needed to make admins dirty and update db
|
|
83
91
|
pipeline.admins = newAdmins;
|
|
92
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
84
93
|
|
|
85
94
|
await pipeline.update();
|
|
86
95
|
}
|
|
@@ -95,8 +95,11 @@ async function updateAdmins(userFactory, username, scmContext, pipeline, pipelin
|
|
|
95
95
|
const newAdmins = pipeline.admins;
|
|
96
96
|
|
|
97
97
|
delete newAdmins[username];
|
|
98
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(adminUserId => adminUserId !== user.id);
|
|
99
|
+
|
|
98
100
|
// This is needed to make admins dirty and update db
|
|
99
101
|
pipeline.admins = newAdmins;
|
|
102
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
100
103
|
|
|
101
104
|
return pipeline.update();
|
|
102
105
|
}
|
|
@@ -110,7 +113,16 @@ async function updateAdmins(userFactory, username, scmContext, pipeline, pipelin
|
|
|
110
113
|
newAdmins[name] = true;
|
|
111
114
|
});
|
|
112
115
|
|
|
116
|
+
const newAdminUserIds = [user.id];
|
|
117
|
+
|
|
118
|
+
pipeline.adminUserIds.forEach(adminUserId => {
|
|
119
|
+
if (adminUserId !== user.id) {
|
|
120
|
+
newAdminUserIds.push(adminUserId);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
113
124
|
pipeline.admins = newAdmins;
|
|
125
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
114
126
|
|
|
115
127
|
return pipeline.update();
|
|
116
128
|
} catch (err) {
|