Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure DevOps - Clean build directory

Just to mention I am using a self-hosted agent for running my build and release pipelines.

The problem is when I run any build and it failed due to some issues in the pipeline. The cloned branch from remote sits in the _work directory. The second run also picks up the same work directory, and I have checked manually from the agent _work directory no new directory was cloned and I can also verify from Azure Pipeline logs they are using the same old directory.

What I did temporarily to solve this, I went into the old directory(i.e. /home/user/_work/13) and manually delete that 13 directories then azure pick it up the new folder say 14 under _work, and I could see the latest cloned code from the remote.

So how to automatically delete the work folder(agent build directory i.e. 13/14 under _work) in case of any failure happen.

PS: I already have cleanup steps in place when my pipeline complete with success, which I run at the end. Also, I am writing .yml based pipelines.

Please let me know if any information is required for a better understanding.

like image 830
Indrajeet Gour Avatar asked Jul 01 '20 14:07

Indrajeet Gour


1 Answers

Azure DevOps - Clean build directory

There is a Clean option on the Get Sources tab, which can perform different kinds of cleaning of the working directory of your private agent before the build is run:

enter image description here

We could set the value to true to clean the working directory of your private agent. Even if the build is failed.

You could check the document Clean the local repo on the agent for some more details.

Update:

But this is meant for the classic pipeline, do not we have any tag which we define in yml pipeline only

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

Check this document YAML schema reference for some details. Hope this helps.

like image 119
Leo Liu-MSFT Avatar answered Oct 23 '22 05:10

Leo Liu-MSFT