azureazure-devopsbuild-pipeline

How to specity workspace clean for hosted agents in Azure DevOps build pipeline for Pipeline with steps and one implicit job?


I am trying to clean the DevOps workspace as described here (Pipeline with Steps and one implicit job)

From what I see, I should add a workspace: row in the YAML, but when I follow the instruction I get an error saying

Unexpected value 'workspace'

The relative pipeline snippet is the following:

pool:
  name: 'Hosted Agents'

workspace:
  clean: all

Solution

  • Differently from what showed in Microsoft documentation here and here , the only way to make this work is adding the workspace element at the same level of the name within the pool:

    pool:
      name: 'Hosted Agents'
      workspace:
        clean: all
    

    And not at the same level of pool