Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Unable to clean workspace directory after publishing artifact #37

orgas002 ·

Hi,

My issue is that my build is unable to clean the workspace directory after the build is done running and after it published the artifacts. It comes out to the error of:

Failed to delete file 'C:\qba\workspace\blah\blah2\blah3\packages\Wix\3.11\candle.exe'.

Keep in mind, the checkout, build, publishing of two artifacts worked, just not the post-execute of clean workspace of current node.

Any help would be great.

  • solved #2
  • replies 1
  • views 994
  • stars 0
robinshen ADMIN ·

Looks like that the file is still being used by some other processes for some reason. You may print the process using the file with below below step:

  1. Download handle.exe and put to the node running the step:
    https://docs.microsoft.com/en-us/sysinternals/downloads/handle
  2. Modify the post-execute action of the step to execute below script:
groovy:
try {
 com.pmease.quickbuild.util.FileUtils.cleanDir(configuration.workspaceDir);
} catch (Exception e) {
  if (e.getMessage().startsWith("Failed to delete file '")) {
    def filePath = e.getMessage().substring("Failed to delete file '".length());
    filePath = filePath.substring(0, filePath.length() - 2);
    logger.info("Detecting processes using: " + filePath);
    def sout = new StringBuilder(), serr = new StringBuilder()
    def proc = 'ls /badDir'.execute()
    proc.consumeProcessOutput(sout, serr)
    proc.waitForOrKill(10000)
    logger.info("out: $sout,  err: $serr");
  }
}