I have written a jenkins scripted pipeline which has 3 stages in it. And in each stage i am calling a curl command to start a jenkins job which is on my remote server. But, the problem is 2nd stage is getting executed before 1st stage completes its execution. Please help me how to resolve this?
node{
properties([
disableConcurrentBuilds()
])
stage('stage1'){
sh 'curl -X POST -H "Content-Type: application/json" -d "{ "tagname": "$tagname" }" -vs http://pkg.rtbrick.com:8080/generic-webhook-trigger/invoke?token=qwerty'
}
stage('stage2'){
sh 'curl -X POST -H "Content-Type: application/json" -d "{ "tagname": "$tagname" }" -vs http://image.rtbrick.com:8080/generic-webhook-trigger/invoke?token=1234'
}
stage('stage3'){
sh 'curl -X POST -H "Content-Type: application/json" -d "{ "tagname": "$tagname" }" -vs http://image.rtbrick.com:8080/generic-webhook-trigger/invoke?token=1804'}
}
}
"Stage2" should start only if "stage1" is completed.