• 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

92.86
/plugins/builds/triggers/orBase.js
1
'use strict';
2

3
const { createInternalBuild, Status, updateVirtualBuildSuccess, hasFreezeWindows } = require('./helpers');
216✔
4

5
/**
6
 * @typedef {import('screwdriver-models').BuildFactory} BuildFactory
7
 * @typedef {import('screwdriver-models').JobFactory} JobFactory
8
 * @typedef {import('screwdriver-models').PipelineFactory} PipelineFactory
9
 * @typedef {import('screwdriver-models/lib/build')} Build
10
 * @typedef {import('screwdriver-models/lib/event')} Event
11
 */
12

13
class OrBase {
14
    /**
15
     * Trigger the next jobs of the current job
16
     * @param {Object} app Server app object
17
     * @param {BuildFactory} app.buildFactory
18
     * @param {JobFactory} app.jobFactory
19
     * @param {PipelineFactory} app.pipelineFactory
20
     * @param {Object} config Configuration object
21
     * @param {Build} config.currentBuild
22
     * @param {String} config.username
23
     * @param {String} config.scmContext
24
     */
25
    constructor(app, config) {
26
        this.buildFactory = app.buildFactory;
112✔
27
        this.jobFactory = app.jobFactory;
112✔
28
        this.pipelineFactory = app.pipelineFactory;
112✔
29

30
        this.currentBuild = config.build;
112✔
31
        this.username = config.username;
112✔
32
        this.scmContext = config.scmContext;
112✔
33
    }
34

35
    /**
36
     * Trigger the next jobs of the current job
37
     * @param {Event} event
38
     * @param {Number} pipelineId
39
     * @param {Job} nextJob
40
     * @param {import('./helpers').ParentBuilds} parentBuilds
41
     * @param {Boolean} isNextJobVirtual
42
     * @return {Promise<Build|null>}
43
     */
44
    async trigger(event, pipelineId, nextJob, parentBuilds, isNextJobVirtual) {
45
        let nextBuild = await this.buildFactory.get({
40✔
46
            eventId: event.id,
47
            jobId: nextJob.id
48
        });
49

50
        const hasWindows = hasFreezeWindows(nextJob);
40✔
51
        const causeMessage = nextJob.name === event.startFrom ? event.causeMessage : '';
40✔
52

53
        if (nextBuild !== null) {
40✔
54
            if (Status.isStarted(nextBuild.status)) {
11✔
55
                return nextBuild;
8✔
56
            }
57

58
            nextBuild.parentBuildId = [this.currentBuild.id];
3✔
59

60
            // Bypass execution of the build if the job is virtual
61
            if (isNextJobVirtual && !hasWindows) {
3!
UNCOV
62
                return updateVirtualBuildSuccess(nextBuild);
×
63
            }
64

65
            nextBuild.status = Status.QUEUED;
3✔
66
            await nextBuild.update();
3✔
67

68
            return nextBuild.start({ causeMessage });
3✔
69
        }
70

71
        nextBuild = await createInternalBuild({
29✔
72
            jobFactory: this.jobFactory,
73
            buildFactory: this.buildFactory,
74
            pipelineId,
75
            jobName: nextJob.name,
76
            jobId: nextJob.id,
77
            username: this.username,
78
            scmContext: this.scmContext,
79
            event,
80
            baseBranch: event.baseBranch || null,
36✔
81
            parentBuilds,
82
            parentBuildId: this.currentBuild.id,
83
            start: hasWindows || !isNextJobVirtual,
58✔
84
            causeMessage
85
        });
86

87
        // Bypass execution of the build if the job is virtual
88
        if (isNextJobVirtual && !hasWindows) {
29✔
89
            await updateVirtualBuildSuccess(nextBuild);
1✔
90
        }
91

92
        return nextBuild;
29✔
93
    }
94
}
95

96
module.exports = {
216✔
97
    OrBase
98
};
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