In my pipeline I have deleteDir() following by git clone. My repo is bit big and have a problem when I rerun the Jenkins pipeline, because deleteDir() is not waiting till the directory has been deleted completely resulting git clone failure. Here is my pippeline
node{
stage ("Clean"){
dir("${Service}") {
deleteDir()
}
}
stage ('Checkout'){
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'abc', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
bat "git clone --recurse-submodules http://${USERNAME}:${PASSWORD}@X.X.X.X:9999/scm/x/${Service}.git"
}
}
}
Please suggest me how I can make clone task to wait till deleteDir() iscompleted
Maybe try to delete the directory in a shell:
sh "rm -rf dirName"