• 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

17.39
/plugins/pipelines/listStages.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 pipelineIdSchema = schema.models.pipeline.base.extract('id');
1✔
7
const nameSchema = schema.models.stage.base.extract('name');
1✔
8
const stageListSchema = schema.models.stage.list;
1✔
9
const STAGE_PR_PATTERN = `PR-%:%`;
1✔
10

11
module.exports = () => ({
434✔
12
    method: 'GET',
13
    path: '/pipelines/{id}/stages',
14
    options: {
15
        description: 'Get all stages for a given pipeline',
16
        notes: 'Returns all stages for a given pipeline',
17
        tags: ['api', 'pipelines', 'stages'],
18
        auth: {
19
            strategies: ['token'],
20
            scope: ['user', 'build', 'pipeline']
21
        },
22

23
        handler: async (request, h) => {
UNCOV
24
            const { pipelineFactory, stageFactory } = request.server.app;
×
UNCOV
25
            const { name, sort, sortBy, page, count, type } = request.query;
×
UNCOV
26
            const pipelineId = request.params.id;
×
27

UNCOV
28
            return pipelineFactory
×
29
                .get(pipelineId)
30
                .then(async pipeline => {
UNCOV
31
                    if (!pipeline) {
×
UNCOV
32
                        throw boom.notFound(`Pipeline ${pipelineId} does not exist`);
×
33
                    }
34

UNCOV
35
                    const config = {
×
36
                        params: { pipelineId },
37
                        sort
38
                    };
39

UNCOV
40
                    if (type === 'pr') {
×
UNCOV
41
                        config.search = {
×
42
                            field: 'name',
43
                            // Do a search for PR-%:% in stage name
44
                            // See https://www.w3schools.com/sql/sql_like.asp for syntax
45
                            keyword: STAGE_PR_PATTERN
46
                        };
47
                    }
48

UNCOV
49
                    if (name) {
×
UNCOV
50
                        config.params = {
×
51
                            ...config.params,
52
                            name
53
                        };
54
                    }
55

UNCOV
56
                    if (sortBy) {
×
UNCOV
57
                        config.sortBy = sortBy;
×
58
                    }
59

UNCOV
60
                    if (page) {
×
UNCOV
61
                        config.paginate = config.paginate || {};
×
UNCOV
62
                        config.paginate.page = page;
×
63
                    }
64

UNCOV
65
                    if (count) {
×
UNCOV
66
                        config.paginate = config.paginate || {};
×
UNCOV
67
                        config.paginate.count = count;
×
68
                    }
69

UNCOV
70
                    return stageFactory.list(config);
×
71
                })
UNCOV
72
                .then(stages => h.response(stages.map(s => s.toJson())))
×
73
                .catch(err => {
UNCOV
74
                    throw err;
×
75
                });
76
        },
77
        response: {
78
            schema: stageListSchema
79
        },
80
        validate: {
81
            params: joi.object({
82
                id: pipelineIdSchema
83
            }),
84
            query: schema.api.pagination.concat(
85
                joi.object({
86
                    name: nameSchema,
87
                    type: joi.string().valid('', 'pr').label('Stage type filter (pr)').optional(),
88
                    search: joi.forbidden() // we don't support search for Pipeline list stages
89
                })
90
            )
91
        }
92
    }
93
});
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