How to use the screwdriver-workflow-parser.getNextJobs function in screwdriver-workflow-parser

To help you get started, we’ve selected a few screwdriver-workflow-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github screwdriver-cd / screwdriver / plugins / builds / index.js View on Github external
server.expose('triggerNextJobs', async (config) => {
        const { pipeline, job, build, username, scmContext, externalJoin } = config;
        const { buildFactory, eventFactory, jobFactory, pipelineFactory } = server.root.app;
        const currentJobName = job.name;
        const pipelineId = pipeline.id;
        const event = await eventFactory.get({ id: build.eventId });
        const workflowGraph = event.workflowGraph;
        const nextJobs = workflowParser.getNextJobs(workflowGraph,
            { trigger: currentJobName, chainPR: pipeline.chainPR });
        // Create a join object like: {A:[B,C], D:[B,F]} where [B,C] join on A, [B,F] join on D, etc.
        // This can include external jobs
        const joinObj = nextJobs.reduce((obj, jobName) => {
            obj[jobName] = workflowParser.getSrcForJoin(workflowGraph, { jobName });

            return obj;
        }, {});

        // Use old flow if external join flag is off
        if (!externalJoin) {
            return Promise.all(Object.keys(joinObj).map((nextJobName) => {
                const joinList = joinObj[nextJobName];
                const joinListNames = joinList.map(j => j.name);
                const buildConfig = {
                    jobFactory,
github screwdriver-cd / screwdriver / plugins / builds / index.js View on Github external
function dfs(workflowGraph, start, builds, visited) {
    const jobId = workflowGraph.nodes.find(node => node.name === start).id;
    const nextJobs = workflowParser.getNextJobs(workflowGraph, { trigger: start });

    // If the start job has no build in parentEvent then just return
    if (!builds.find(build => build.jobId === jobId)) {
        return visited;
    }

    visited.add(builds.find(build => build.jobId === jobId).id);
    nextJobs.forEach(job => dfs(workflowGraph, job, builds, visited));

    return visited;
}
github screwdriver-cd / screwdriver / plugins / webhooks / index.js View on Github external
function hasTriggeredJob(pipeline, startFrom) {
    try {
        const nextJobs = workflowParser.getNextJobs(pipeline.workflowGraph, {
            trigger: startFrom
        });

        return nextJobs.length > 0;
    } catch (err) {
        logger.error(`Error finding triggered jobs for ${pipeline.id}: ${err}`);

        return false;
    }
}
github screwdriver-cd / screwdriver / plugins / pipelines / badge.js View on Github external
function dfs(workflowGraph, start, prNum) {
    let nextJobsConfig;

    if (start === '~pr') {
        nextJobsConfig = {
            trigger: start,
            prNum
        };
    } else {
        nextJobsConfig = {
            trigger: start
        };
    }

    const nextJobs = workflowParser.getNextJobs(workflowGraph, nextJobsConfig);

    let visited = new Set(nextJobs);

    nextJobs.forEach((job) => {
        const subJobs = dfs(workflowGraph, job);

        visited = new Set([...visited, ...subJobs]);
    });

    return visited;
}

screwdriver-workflow-parser

Parses and converts pipeline configuration into a workflow

BSD-3-Clause
Latest version published 29 days ago

Package Health Score

79 / 100
Full package analysis