1
votes

I am trying to execute Jenkins Pipeline build from legacy Upstream-Downstream jobs.

    node () {
stage('Checkout') {
    <Code for checkout> 
    }
stage ('Support') {
    <Restore dependencies>
    <Restore build environment>
    }
    stages{
        parallel{
            stage ('Build and Archive'){
                stages{
                    stage ('BuildSolution') {
                        <Build Solution>
                        }
                    stage ('Signing') {
                        <Sign deliverables>
                        }
                    stage ('InstallerCreation') {
                        <Create deployment package>
                        }

                    stage ('CreateNgPkg') {
                        <Create SDK package>
                        }
                    }
                }
            stage ('SecurityScan'){
                <Execute scan on the complete source code>
                }
            }
        }
    }
}

I want to run stage ('Build') and stage ('Scan') in parallel and after stage ('Build') is executed it should start stage ('CreateNgPkg') without checking or waiting for stage ('Scan')


UPDATE:

I tried using the above nested Stages to achieve what i needed but it's giving error "No such DSL method 'stages' found among steps" upon execution. -No syntax error, just this at run time.

1
why not add it as a nother parallel job? or do you mean stage("Build") has to finish not only be executed?marxmacher

1 Answers

0
votes

What you want to do is to execute the set of stages Build, then CreateNgPkg in parallel with the stage Scan

It translates to the following Jenkins DSL:

node () {
    stage ('Checkout') 
    {
        echo 'Checkout'
    }
    stage ('Support') 
    {
        echo 'Support'
    }
    parallel Build: {
        stage ('Build') 
        {
            echo 'build'
        }
        stage ('CreateNgPkg') 
        {
            echo 'CreateNgPkg'
        }
    }, secondStage: {
        stage ('Scan') 
        {
            echo 'scan'
        }
    }
}

I personally prefer the declarative dsl which is way better documented and can be linted https://jenkins.io/blog/2017/09/25/declarative-1/