• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

screwdriver-cd / screwdriver / #3202

25 Jul 2025 04:52PM UTC coverage: 67.669% (-27.3%) from 94.935%
#3202

push

screwdriver

web-flow
feat(3363): Update the existing endpoint to get admin for a pipeline from the specified SCM context (#3370)

1284 of 2114 branches covered (60.74%)

Branch coverage included in aggregate %.

1 of 11 new or added lines in 1 file covered. (9.09%)

1235 existing lines in 49 files now uncovered.

3417 of 4833 relevant lines covered (70.7%)

50.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.69
/plugins/pipelines/syncWebhooks.js
1
'use strict';
2

3
const boom = require('@hapi/boom');
1✔
4
const joi = require('joi');
1✔
5
const schema = require('screwdriver-data-schema');
1✔
6
const idSchema = schema.models.pipeline.base.extract('id');
1✔
7
const { getUserPermissions, getScmUri } = require('../helper');
1✔
8

9
module.exports = () => ({
434✔
10
    method: 'POST',
11
    path: '/pipelines/{id}/sync/webhooks',
12
    options: {
13
        description: 'Add webhooks or update webhooks if already exists',
14
        notes: 'Add or update Screwdriver API webhooks',
15
        tags: ['api', 'pipelines'],
16
        auth: {
17
            strategies: ['token'],
18
            scope: ['user', '!guest']
19
        },
20

21
        handler: async (request, h) => {
UNCOV
22
            const { id } = request.params;
×
UNCOV
23
            const { pipelineFactory, userFactory } = request.server.app;
×
UNCOV
24
            const { username, scmContext, scope } = request.auth.credentials;
×
25

26
            // Fetch the pipeline and user models
UNCOV
27
            const [pipeline, user] = await Promise.all([
×
28
                pipelineFactory.get(id),
29
                userFactory.get({ username, scmContext })
30
            ]);
31

UNCOV
32
            if (!pipeline) {
×
UNCOV
33
                throw boom.notFound('Pipeline does not exist');
×
34
            }
UNCOV
35
            if (pipeline.state === 'DELETING') {
×
UNCOV
36
                throw boom.conflict('This pipeline is being deleted.');
×
37
            }
UNCOV
38
            if (!user) {
×
UNCOV
39
                throw boom.notFound(`User ${username} does not exist`);
×
40
            }
41

UNCOV
42
            if (!scope.includes('admin')) {
×
43
                // Use parent's scmUri if pipeline is child pipeline and using read-only SCM
UNCOV
44
                const scmUri = await getScmUri({ pipeline, pipelineFactory });
×
45

46
                // Check the user's permission
UNCOV
47
                await getUserPermissions({ user, scmUri, level: 'push' });
×
48
            }
49

50
            // user has good permissions, add or update webhooks
UNCOV
51
            await pipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`);
×
52

UNCOV
53
            return h.response().code(204);
×
54
        },
55
        validate: {
56
            params: joi.object({
57
                id: idSchema
58
            })
59
        }
60
    }
61
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc