0

I wrote below code to execute jobs in sequence in Pipeline script Jenkins, but I have a requirement to run 'build' and 'Undeploy' from below as parallel and then 'Deploy' after that

node: {
  stage 'build'
  build job: 'JenkinsTest', parameters: [
    [$class: 'StringParameterValue', name: 'VERSION', value: "${VERSION}"],
    [$class: 'StringParameterValue', name: 'RBFLAG', value: "${RBFLAG}"],
    [$class: 'StringParameterValue', name: 'SET_ENV', value: "${SET_ENV}"]
    ]

stage 'Undeploy'
build job:  'Undeploy job', parameters: [
    [$class: 'StringParameterValue', name: 'RBFLAG', value: "${RBFLAG}"]
    ]

stage 'Deploy'
build job:  'Deploy job', parameters: [
    [$class: 'StringParameterValue', name: 'RBFLAG', value: "${RBFLAG}"]
    ]
}

Please help.

San
  • 226
  • 5
  • 14

1 Answers1

2

Give it a try with something like below, using parallel: 1

pipeline {
agent any   
stages {
    stage('First Stage'){
        steps{
            script{
                parallel(
                        "build":{
                            build job: 'JenkinsTest', parameters: [
                                [$class: 'StringParameterValue', name: 'VERSION', value: "${VERSION}"],
                                [$class: 'StringParameterValue', name: 'RBFLAG', value: "${RBFLAG}"],
                                [$class: 'StringParameterValue', name: 'SET_ENV', value: "${SET_ENV}"]
                                ]
                        },
                        "undeploy":{
                           build job:  'Undeploy job', parameters: [
                            [$class: 'StringParameterValue', name: 'RBFLAG', value: "${RBFLAG}"]
                            ]
                        }
                )
            }
        }
    }
    stage('Second stage') {
        steps{
            script{
                build job:  'Deploy job', parameters: [
                    [$class: 'StringParameterValue', name: 'RBFLAG', value: "${RBFLAG}"]
                    ]
                }
            }
    }
}

}

nandilov
  • 699
  • 8
  • 18