azuredevops icon indicating copy to clipboard operation
azuredevops copied to clipboard

Add retry handling for `rmRF` invocation in `dependency-check-build-task.ts`

Open hlovdal opened this issue 7 months ago • 0 comments

azuredevops/src/Tasks/dependency-check-build-task/dependency-check-build-task.ts contains

    await console.log('Downloading ZIP from "' + zipUrl + '"...');
    ...
    tl.rmRF(zipLocation);

however this file removal is not unlikely to fail if an anti-virus program is currently scanning the file or some other file monitoring program holds the file open. Such failures breaks the build:

Downloading ZIP from "https://github.com/jeremylong/DependencyCheck/releases/download/v8.4.3/dependency-check-8.4.3-release.zip"...
Failed rmRF: EPERM: operation not permitted, unlink 'C:\Agent\_work\_tasks\dependency-check-build-task_47ea1f4a-57ba-414a-b12e-c44f42765e72\6.1.1\dependency-check-8.4.3-release.zip'
##[error]Failed rmRF: EPERM: operation not permitted, unlink 'C:\Agent\_work\_tasks\dependency-check-build-task_47ea1f4a-57ba-414a-b12e-c44f42765e72\6.1.1\dependency-check-8.4.3-release.zip'
##[error]Unhandled error condition detected.
Ending Dependency Check...

It would be nice if the file remove operation was wrapped with retry policy handling similar to the what is used for downloading, with an additional time delay between attempts (say exponential back-off up till 2-5 minutes), so that there is a chance of recovery from such removal failures.

hlovdal avatar Nov 16 '23 16:11 hlovdal