• 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

21.62
/plugins/pipelines/listJobs.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 jobListSchema = joi.array().items(schema.models.job.get).label('List of jobs');
1✔
7
const jobNameSchema = schema.models.job.base.extract('name');
1✔
8
const pipelineIdSchema = schema.models.pipeline.base.extract('id');
1✔
9
const JOB_PR_PATTERN = `PR-%:%`;
1✔
10

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

23
        handler: async (request, h) => {
UNCOV
24
            const { pipelineFactory } = request.server.app;
×
UNCOV
25
            const { page, count, jobName, type } = request.query;
×
26

UNCOV
27
            return pipelineFactory
×
28
                .get(request.params.id)
29
                .then(pipeline => {
UNCOV
30
                    if (!pipeline) {
×
UNCOV
31
                        throw boom.notFound('Pipeline does not exist');
×
32
                    }
33

UNCOV
34
                    const config = {
×
35
                        params: {
36
                            archived: request.query.archived
37
                        }
38
                    };
39

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

UNCOV
48
                        if (type === 'pipeline') {
×
49
                            // Do a search for job name without PR-%:% pattern
50
                            // See https://www.w3schools.com/sql/sql_not.asp for syntax
UNCOV
51
                            config.search.inverse = true;
×
52
                        }
53
                    }
UNCOV
54
                    if (jobName) {
×
UNCOV
55
                        config.params.name = jobName;
×
56
                    }
UNCOV
57
                    if (page || count) {
×
UNCOV
58
                        config.paginate = { page, count };
×
59
                    }
60

UNCOV
61
                    return pipeline.getJobs(config);
×
62
                })
UNCOV
63
                .then(jobs => h.response(jobs.map(j => j.toJson())))
×
64
                .catch(err => {
UNCOV
65
                    throw err;
×
66
                });
67
        },
68
        response: {
69
            schema: jobListSchema
70
        },
71
        validate: {
72
            params: joi.object({
73
                id: pipelineIdSchema
74
            }),
75
            query: schema.api.pagination.concat(
76
                joi.object({
77
                    type: joi.string().valid('', 'pr', 'pipeline').label('Job type filter (pr or pipeline)').optional(),
78
                    archived: joi.boolean().truthy('true').falsy('false').default(false),
79
                    jobName: jobNameSchema,
80
                    search: joi.forbidden(), // we don't support search for Pipeline list jobs
81
                    getCount: joi.forbidden(),
82
                    sortBy: joi.forbidden()
83
                })
84
            )
85
        }
86
    }
87
});
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