screwdriver-api 8.0.69 → 8.0.71
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": "8.0.
|
|
3
|
+
"version": "8.0.71",
|
|
4
4
|
"description": "API server for the Screwdriver.cd service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -125,10 +125,10 @@
|
|
|
125
125
|
"screwdriver-notifications-email": "^5.0.0",
|
|
126
126
|
"screwdriver-notifications-slack": "^7.0.0",
|
|
127
127
|
"screwdriver-request": "^3.0.0",
|
|
128
|
-
"screwdriver-scm-base": "^10.0.
|
|
129
|
-
"screwdriver-scm-bitbucket": "^7.
|
|
130
|
-
"screwdriver-scm-github": "^14.1
|
|
131
|
-
"screwdriver-scm-gitlab": "^5.
|
|
128
|
+
"screwdriver-scm-base": "^10.0.1",
|
|
129
|
+
"screwdriver-scm-bitbucket": "^7.4.1",
|
|
130
|
+
"screwdriver-scm-github": "^14.5.1",
|
|
131
|
+
"screwdriver-scm-gitlab": "^5.5.1",
|
|
132
132
|
"screwdriver-scm-router": "^9.0.0",
|
|
133
133
|
"screwdriver-template-validator": "^10.0.0",
|
|
134
134
|
"screwdriver-workflow-parser": "^6.1.0",
|
package/plugins/auth/index.js
CHANGED
|
@@ -230,6 +230,17 @@ const authPlugin = {
|
|
|
230
230
|
scmContext: user.scmContext,
|
|
231
231
|
scope: ['user']
|
|
232
232
|
};
|
|
233
|
+
|
|
234
|
+
const scmDisplayName = scm.getDisplayName({ scmContext: profile.scmContext });
|
|
235
|
+
const userDisplayName = pluginOptions.authCheckById
|
|
236
|
+
? `${scmDisplayName}:${profile.username}:${profile.scmUserId}`
|
|
237
|
+
: `${scmDisplayName}:${profile.username}`;
|
|
238
|
+
const admins = pluginOptions.authCheckById ? pluginOptions.sdAdmins : pluginOptions.admins;
|
|
239
|
+
|
|
240
|
+
// Check admin
|
|
241
|
+
if (admins.length > 0 && admins.includes(userDisplayName)) {
|
|
242
|
+
profile.scope.push('admin');
|
|
243
|
+
}
|
|
233
244
|
}
|
|
234
245
|
if (token.pipelineId) {
|
|
235
246
|
// if token has pipelineId then the token is for pipeline
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { PR_JOB_NAME } = require('screwdriver-data-schema/config/regex');
|
|
3
4
|
const { updateBuildAndTriggerDownstreamJobs } = require('../../builds/helper/updateBuild');
|
|
4
5
|
const { Status, BUILD_STATUS_MESSAGES } = require('../../builds/triggers/helpers');
|
|
5
6
|
|
|
@@ -9,19 +10,40 @@ const { Status, BUILD_STATUS_MESSAGES } = require('../../builds/triggers/helpers
|
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
*
|
|
12
|
-
* @param
|
|
13
|
+
* @param virtualNodeNames
|
|
14
|
+
* @param prJobs
|
|
13
15
|
* @returns {Array<Number>}
|
|
14
16
|
*/
|
|
15
|
-
function getVirtualJobIds(
|
|
17
|
+
function getVirtualJobIds(virtualNodeNames, prJobs) {
|
|
16
18
|
const virtualJobIds = [];
|
|
17
19
|
|
|
20
|
+
prJobs.forEach(prJob => {
|
|
21
|
+
const prJobName = prJob.name.match(PR_JOB_NAME);
|
|
22
|
+
const nodeName = prJobName ? prJobName[2] : prJob.name;
|
|
23
|
+
|
|
24
|
+
if (virtualNodeNames.includes(nodeName)) {
|
|
25
|
+
virtualJobIds.push(prJob.id);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return virtualJobIds;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param workflowGraph
|
|
35
|
+
* @returns {Array}
|
|
36
|
+
*/
|
|
37
|
+
function getVirtualJobNames(workflowGraph) {
|
|
38
|
+
const virtualJobNames = [];
|
|
39
|
+
|
|
18
40
|
workflowGraph.nodes.forEach(node => {
|
|
19
41
|
if (node.virtual) {
|
|
20
|
-
|
|
42
|
+
virtualJobNames.push(node.name);
|
|
21
43
|
}
|
|
22
44
|
});
|
|
23
45
|
|
|
24
|
-
return
|
|
46
|
+
return virtualJobNames;
|
|
25
47
|
}
|
|
26
48
|
|
|
27
49
|
/**
|
|
@@ -37,26 +59,39 @@ function getVirtualJobIds(workflowGraph) {
|
|
|
37
59
|
* @returns {Promise<Event>} Newly created event
|
|
38
60
|
*/
|
|
39
61
|
async function createEvent(config, server) {
|
|
40
|
-
const { eventFactory } = server.app;
|
|
62
|
+
const { eventFactory, jobFactory } = server.app;
|
|
41
63
|
const { username, scmContext } = config;
|
|
42
64
|
const event = await eventFactory.create(config);
|
|
43
|
-
const virtualJobIds = getVirtualJobIds(event.workflowGraph);
|
|
44
65
|
|
|
45
66
|
if (event.builds) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
67
|
+
const jobIds = event.builds.map(b => b.jobId);
|
|
68
|
+
|
|
69
|
+
const virtualNodeNames = getVirtualJobNames(event.workflowGraph);
|
|
70
|
+
|
|
71
|
+
if (virtualNodeNames.length > 0) {
|
|
72
|
+
const prJobs = await jobFactory.list({
|
|
73
|
+
params: {
|
|
74
|
+
id: jobIds
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const virtualJobIds = getVirtualJobIds(virtualNodeNames, prJobs);
|
|
79
|
+
|
|
80
|
+
const virtualJobBuilds = event.builds.filter(b => virtualJobIds.includes(b.jobId));
|
|
81
|
+
|
|
82
|
+
for (const build of virtualJobBuilds) {
|
|
83
|
+
await updateBuildAndTriggerDownstreamJobs(
|
|
84
|
+
{
|
|
85
|
+
status: Status.SUCCESS,
|
|
86
|
+
statusMessage: BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage,
|
|
87
|
+
statusMessageType: BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType
|
|
88
|
+
},
|
|
89
|
+
build,
|
|
90
|
+
server,
|
|
91
|
+
username,
|
|
92
|
+
scmContext
|
|
93
|
+
);
|
|
94
|
+
}
|
|
60
95
|
}
|
|
61
96
|
}
|
|
62
97
|
|