Issue
I'm trying to delete a specific custom folder of generated sources in my Jenkins build but cannot figure out the right way to do this using a Jenkinsfile.
Here's what I've tried so far:
dir('target\generated-sources\something') {
deleteDir()
}
dir(???)
Here my problem is that I cannot figure out how to navigate back up, I cannot find a conclusive documentation on how to do this...
I've also tried remembering the PWD before and then navigatig back to the old PWD, but I cannot figure out how to do that either.
The other way would be to delete it straight away using cmd or bat, something like this:
cmd rmdir target/generated-sources/something
But now I'm stuck in quotation hell. Somebody must have done something similar before, I'm not familiar with the Groovy language nor with editing Jenkinsfiles either. Does anybody know?
Solution
I just figured it out:
bat rmdir \"target/generated-sources/something\" /S /Q
There was an additional catch, the bat or cmd or whatever exe is executing the delete operation is refusing to delete the folder if it is not empty. Some MSDN site said you can use /S to delete the entire tree directory tree including the stated folder and the /Q turns it quiet i.e. forces the operation (like -f in PowerShell)
Answered By - DanDan
Answer Checked By - Clifford M. (JavaFixing Volunteer)