Pipeline script : Run job once the first job finishes.

22 views
Skip to first unread message

Apurba Sarkar

unread,
May 21, 2018, 9:13:40 AM5/21/18
to Jenkins Users

Hi All,

 

I am very much new to Jenkins.  I need your help.

 

I have 2 jobs:

 

Misc_Jobs/VM_Request_And_Validation

 

Misc_Jobs/SS_Install_Jboss

 

 

I have created one simple pipeline using  Groovy Pipelines where the jobs should run one after another.

 

node {

    stage('Build Virtual Machine') {

      

        build job: 'Misc_Jobs/VM_Request_And_Validation', parameters: [

            string(name: 'Hostname', value:'satclient8'),

            string(name:'DSType', value: "NAS")], wait: true

      

    }

    stage('Post Installation Stage') {

      

        build job: 'Misc_Jobs/SS_Install_Jboss', parameters: [

            string(name: 'Hostname', value:'satclient8'),

            string(name:'DSType', value: "NAS")]

      

    }

}

 

 

However I observed that the second job start running immediately after the first one.

How to correct my script.

Regards,

Apurba

Ramanathan Muthaiah

unread,
May 21, 2018, 11:09:10 AM5/21/18
to Jenkins Users

 node {

    stage('Build Virtual Machine') {

      

        build job: 'Misc_Jobs/VM_Request_And_Validation', parameters: [

            string(name: 'Hostname', value:'satclient8'),

            string(name:'DSType', value: "NAS")], wait: true

      

    }

    stage('Post Installation Stage') {

      

        build job: 'Misc_Jobs/SS_Install_Jboss', parameters: [

            string(name: 'Hostname', value:'satclient8'),

            string(name:'DSType', value: "NAS")]

      

    }

}

 

 

However I observed that the second job start running immediately after the first one.


Another option is to use 'when' directive, https://jenkins.io/doc/book/pipeline/syntax/#when

/Ram 
Reply all
Reply to author
Forward
0 new messages