How to clean target directory before downloading artifact into it?

Viewed 923

We ran into an issue where the same script used to deploy locally was giving unexpected behavior on remote server. After lot of debugging we found that this is because the download step in our Azure Pipeline:

steps:
  - download: current

does not overwrite the target directory i.e., any files left behind from previous runs will remain there and can cause unintended side-effects. Is there any way to tell the Azure pipeline to clean the target directory and remove everything in it before downloading the artifact?

1 Answers

How to clean target directory before downloading artifact into it?

You could set clean the workspace by following syntax:

jobs:
- job: string  # name of the job (A-Z, a-z, 0-9, and underscore)
  ...
  workspace:
    clean: outputs | resources | all # what to clean up before the job runs

You could this document YAML schema reference for some details.

Related