• 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

11.11
/plugins/pipelines/helper/updateAdmins.js
1
'use strict';
2

3
const boom = require('@hapi/boom');
1✔
4
const logger = require('screwdriver-logger');
1✔
5

6
/**
7
 * @typedef {import('screwdriver-models/lib/pipeline')} Pipeline
8
 */
9

10
/**
11
 * Adds the users as admins for the specified pipeline
12
 *
13
 * @method updateBuildAndTriggerDownstreamJobs
14
 * @param   {Object}    config
15
 * @param   {Number}    config.id Pipeline id
16
 * @param   {Array}     [config.usernames] List of usernames to be added as admins to the pipeline
17
 * @param   {String}    config.scmContext SCM Context the users are associated with
18
 * @param   {Object}    server
19
 * @returns {Promise<Pipeline>} Updated pipeline
20
 */
21
async function updatePipelineAdmins(config, server) {
UNCOV
22
    const { pipelineFactory, userFactory } = server.app;
×
UNCOV
23
    const { id, scmContext, usernames } = config;
×
24

UNCOV
25
    const pipeline = await pipelineFactory.get({ id });
×
26

27
    // check if pipeline exists
UNCOV
28
    if (!pipeline) {
×
UNCOV
29
        throw boom.notFound(`Pipeline ${id} does not exist`);
×
30
    }
UNCOV
31
    if (pipeline.state === 'DELETING') {
×
UNCOV
32
        throw boom.conflict('This pipeline is being deleted.');
×
33
    }
34

UNCOV
35
    const users = await userFactory.list({
×
36
        params: {
37
            username: usernames,
38
            scmContext
39
        }
40
    });
41

UNCOV
42
    const adminUsernamesForUpdate = [];
×
UNCOV
43
    const newAdmins = new Set(pipeline.adminUserIds);
×
44

UNCOV
45
    users.forEach(user => {
×
UNCOV
46
        newAdmins.add(user.id);
×
UNCOV
47
        adminUsernamesForUpdate.push(user.username);
×
48
    });
49

UNCOV
50
    pipeline.adminUserIds = Array.from(newAdmins);
×
51

UNCOV
52
    try {
×
UNCOV
53
        const updatedPipeline = await pipeline.update();
×
54

UNCOV
55
        logger.info(`Updated admins ${adminUsernamesForUpdate} for pipeline(id=${id})`);
×
56

UNCOV
57
        return updatedPipeline;
×
58
    } catch (err) {
59
        logger.error(`Failed to update admins ${adminUsernamesForUpdate} for pipeline(id=${id}): ${err.message}`);
×
60
        throw boom.internal(`Failed to update admins for pipeline ${id}`);
×
61
    }
62
}
63

64
module.exports = {
1✔
65
    updatePipelineAdmins
66
};
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