Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean All build directories in Azure DevOps Pipeline settings is not working while using YAML configuration

I use Azure DevOps for some time, and I always use Classic Editor GUI when crafting Build Pipeline. Now I'm trying to create new pipeline using YAML. Everything went well and the build was successful. But, I have noticed different behavior in checkout task compared to pipeline using Classic Editor. In both pipelines, settings used in 'Get sources' tab are same(see the below screenshot)

enter image description here

In case of Classic Editor pipeline, checkout task Deletes and recreates $(Agent.BuildDirectory). This results in initializing a new, local Git repository for every build. But, for YAML pipeline, checkout task only performing a git clean -ffdx and removing source directories only. How to resolve this issue for YAML pipelines?

YAML pipeline log:

enter image description here

Classic Editor pipeline log:

enter image description here

like image 222
rinesh Avatar asked Jan 26 '23 02:01

rinesh


2 Answers

Setting clean all build directories option(in below screenshot) in devops UI is not working in case of YAML builds.

enter image description here

But you can specify this in YAML file itself by using the workspace setting of a Job. This is working as expected.

jobs:
- job: Job1
  workspace:
    clean: all # what to clean up before the job runs - outputs | resources | all
like image 72
rinesh Avatar answered Jan 28 '23 11:01

rinesh


It is really strange because I have this (in YAML build)

enter image description here

I found this in documentation:

When clean is set to true the build pipeline performs an undo of any changes in $(Build.SourcesDirectory). More specifically, the following Git commands are executed prior to fetching the source.

git clean -ffdx
git reset --hard HEAD

Do you have clean option enabled?

like image 25
Krzysztof Madej Avatar answered Jan 28 '23 09:01

Krzysztof Madej