Hi,

Sorry, I completely forgot to respond.

I'm not sure if there is an existing reported JIRA bug for this.
https://issues.jenkins-ci.org/browse/JENKINS-15331
Not sure when this fix was release. It does seems like we are running with 
it according to the exception it throws. I recall getting a different 
exception previosuly before I added the try-catch surrounding the deleteDir.

My scripted pipeline
node(nodeName) {
    unstash 'archive'
    sh "tar -zxf ${projectName}.tar.gz"

    try {
        tool name: 'gradle-4.8', type: 'gradle'
        sh "gradle ${javaOptions} --refresh-dependencies ${buildTask} 
${releaseProperty} -Pheadless"

        stash allowEmpty: true, includes: "build/**/*.rpm", name: stashName

        /* Archive Linux FPM packages */
        archiveArtifacts allowEmptyArchive: true, artifacts: 
"build/**/*.rpm", onlyIfSuccessful: true

        /* Archive Windows native executables. */
        archiveArtifacts allowEmptyArchive: true, artifacts: 
"build/**/*.exe", excludes: "build/**/${projectName}/*.exe", 
onlyIfSuccessful: true
    } catch (e) {
        throw e
    } finally {
        try {
            deleteDir()
        } catch (e) {
            println e
        }
    }
}


I had to wrap the deleteDir within a try-catch, because otherwise it would 
sometimes fail the build.
The downside is with this I sometimes get a workspace with pre-existing 
build artifacts.
        
java.io.IOException: Unable to delete 
'C:\cygwin64\home\build\jenkins\workspace\application_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ\build\deploy\package\windows\application.iss'.
 
Tried 3 times (of a maximum of 3) waiting 0,1 sec between attempts.


torsdag 11. oktober 2018 10.02.54 UTC+2 skrev Baptiste Mathus følgende:
>
> What is the JIRA number number for the Windows deleteDir() bug you say 
> you're seeing? 
>
> Le jeu. 11 oct. 2018 à 09:33, Sverre Moe <[email protected] <javascript:>> 
> a écrit :
>
>> This deleteDir() does not always work on a Windows build slave.
>>
>> Using Scripted PIpeline I am declaring a node within try-catch-finally.
>> The finally will run deleteDir(), in order to delete the build workspace. 
>> This is done in order to get a fresh build each time. I cannot risk having 
>> stale data lying around from a previous builds.
>>
>> Is there some other means I can make sure that the build has a clean 
>> workspace?
>>
>> 1) Always build with clean
>> mvn clean deploy
>> gradle clean build publish
>>
>> 2) SCM configuration
>> *Clean after checkout*
>> *Clean before checkout*
>>
>> *3) Windows working deleteDir()*
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/966a8838-f95a-4c23-ac61-e4c7356fac8d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/966a8838-f95a-4c23-ac61-e4c7356fac8d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/60b50a51-2b75-4e4e-82bb-32d9f1dc99e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to