1

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

4

2 回答 2

2

也许尝试在 shell 中删除目录:

sh "rm -rf dirName"
于 2018-03-02T22:55:10.117 回答
1

请发表评论,我没有足够的评价。在Jenkins问题中,有许多与deleteDir(). 所以@Frankenstein解决方案是一个很好的解决方法。

于 2018-03-06T14:32:27.173 回答