• 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.59
/plugins/pipelines/admins/get.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 getSchema = schema.models.pipeline.base.extract('admins').get;
1✔
7
const idSchema = schema.models.pipeline.base.extract('id');
1✔
8
const scmContextSchema = schema.models.pipeline.base.extract('scmContext');
1✔
9

10
module.exports = () => ({
434✔
11
    method: 'GET',
12
    path: '/pipelines/{id}/admin',
13
    options: {
14
        description: 'Get the pipeline admin',
15
        notes: 'Returns a pipeline admin record',
16
        tags: ['api', 'pipelines'],
17
        auth: {
18
            strategies: ['token'],
19
            scope: ['user', 'admin', 'pipeline', '!guest']
20
        },
21

22
        handler: async (request, h) => {
NEW
23
            const pipelineFactory = request.server.app.pipelineFactory;
×
NEW
24
            const { scope } = request.auth.credentials;
×
NEW
25
            const { scmContext, includeUserToken } = request.query;
×
26

NEW
27
            if (includeUserToken && !scope.includes('admin')) {
×
NEW
28
                throw boom.forbidden('Only Screwdriver admin is allowed to request user token');
×
29
            }
30

NEW
31
            const pipeline = await pipelineFactory.get(request.params.id);
×
32

UNCOV
33
            if (!pipeline) {
×
34
                throw boom.notFound('Pipeline does not exist');
×
35
            }
36

UNCOV
37
            try {
×
38
                const admin =
NEW
39
                    scmContext && scmContext !== pipeline.scmContext
×
40
                        ? await pipeline.getFirstAdmin({ scmContext })
41
                        : await pipeline.getFirstAdmin();
42

NEW
43
                if (includeUserToken) {
×
NEW
44
                    const profile = request.server.plugins.auth.generateProfile({
×
45
                        username: admin.username,
46
                        scmContext: admin.scmContext,
47
                        scope: ['user']
48
                    });
49

NEW
50
                    admin.userToken = request.server.plugins.auth.generateToken(profile);
×
51
                }
52

UNCOV
53
                return h.response(admin);
×
54
            } catch (e) {
UNCOV
55
                throw boom.notFound(e);
×
56
            }
57
        },
58
        response: {
59
            schema: getSchema
60
        },
61
        validate: {
62
            params: joi.object({
63
                id: idSchema
64
            }),
65
            query: joi.object({
66
                scmContext: scmContextSchema.optional(),
67
                includeUserToken: joi.boolean().optional()
68
            })
69
        }
70
    }
71
});
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