Warm tip: This article is reproduced from stackoverflow.com, please click
azure-devops azure-pipelines

How stop Azure Pipeline Self-Hosted agent to delete sources

发布于 2020-04-11 22:25:10

I have an Azure Pipeline Self-Hosted agent (Windows) I configured on one of my laptops, so everything is persistent; the pipeline that uses that, clones the repository, then runs a CMake configure which further downloads several submodules through git submodule update --init.

Although I think I configured the pipeline in any way I could to only clean outputs, so binaries, not sources, on each new run the submodules gets downloaded again.
I know that it starts with an empty repostory because in the checkout step log I see:

git init "C:\agent\_work\3\s"
Initialized empty Git repository in C:/agent/_work/3/s/.git/

I've checked here https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#job and set the workspace attribute clean to clean: outputs.
Checked here https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#checkout and set the checkout attribute clean to clean: false.
I've also controlled that the configuration of the pipeline on the website had not the clean attribute active.

I seem to recall somewhere around 6 months ago or more (when you had clean: binaries instead), that this was working correctly.

Here is a very simplified version of what the pipeline looks like:

jobs:
  - job: AJob
    displayName: "A job"

    pool: "Self Hosted"

    workspace:
      clean: outputs

    steps:
    - powershell: |
        git config --global core.autocrlf false
        git config --global core.symlinks true

    - checkout: self
      clean: false

    - powershell: |
        git submodule update --init <path to submodule>

EDIT: To add even more info, enabling the debug variable for the run I see this in the log when it initializes the Job:

##[debug]Delete existing build directory: 'C:\agent\_work\3' <---- why :\
##[debug]Deleting build directory: 'C:\agent\_work\3'
##[debug]Creating build directory: 'C:\agent\_work\3'
##[debug]Delete existing artifacts directory: 'C:\agent\_work\3\a'
##[debug]Creating artifacts directory: 'C:\agent\_work\3\a'
##[debug]Delete existing test results directory: 'C:\agent\_work\3\TestResults'
##[debug]Creating test results directory: 'C:\agent\_work\3\TestResults'
##[debug]Creating binaries directory: 'C:\agent\_work\3\b'
##[debug]Creating source directory: 'C:\agent\_work\3\s'

Is anyone else experiencing this and knows how to resolve?

Questioner
Smjert
Viewed
117
Smjert 2020-02-03 18:27

Discovered that it was the variable build.clean: all set through the UI, from another portion I didn't look at.
Specifically this was in the Variables tab when editing the pipeline.
Simpler than I thought.