title | description | ms.date | monikerRange |
---|---|---|---|
DeleteFiles@1 - Delete files v1 task |
Delete folders, or files matching a pattern. |
07/02/2024 |
<=azure-pipelines |
:::moniker range=">=azure-pipelines-2019.1"
Delete folders, or files matching a pattern.
:::moniker-end
:::moniker range="=azure-pipelines-2019"
Delete files or folders. (The minimatch patterns will only match file paths, not folder paths).
:::moniker-end
:::moniker range=">=azure-pipelines-2022"
# Delete files v1
# Delete folders, or files matching a pattern.
- task: DeleteFiles@1
inputs:
#SourceFolder: # string. Source Folder.
Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.
#RemoveSourceFolder: false # boolean. Remove SourceFolder. Default: false.
# Advanced
#RemoveDotFiles: false # boolean. Remove files starting with a dot. Default: false.
:::moniker-end
:::moniker range=">=azure-pipelines-2020 <=azure-pipelines-2020.1"
# Delete files v1
# Delete folders, or files matching a pattern.
- task: DeleteFiles@1
inputs:
#SourceFolder: # string. Source Folder.
Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.
#RemoveSourceFolder: false # boolean. Remove SourceFolder. Default: false.
:::moniker-end
:::moniker range="=azure-pipelines-2019.1"
# Delete files v1
# Delete folders, or files matching a pattern.
- task: DeleteFiles@1
inputs:
#SourceFolder: # string. Source Folder.
Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.
:::moniker-end
:::moniker range="=azure-pipelines-2019"
# Delete Files v1
# Delete files or folders. (The minimatch patterns will only match file paths, not folder paths).
- task: DeleteFiles@1
inputs:
#SourceFolder: # string. Source Folder.
Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.
:::moniker-end
:::moniker range="<=azure-pipelines"
SourceFolder
- Source Folder
string
.
If the source folder is empty, the task deletes files from the root folder of the repository as though $(Build.SourcesDirectory) was specified.
If your build produces artifacts outside of the sources directory, specify $(Agent.BuildDirectory)
to delete files from the build agent working directory.
:::moniker-end
:::moniker range="<=azure-pipelines"
Contents
- Contents
string
. Required. Default value: myFileShare
.
The file/folder paths to delete. Supports multiple lines of minimatch patterns; each one is processed before moving onto the next line. Learn more about File matching patterns. For example:
**/*
deletes all files and folders in the root folder.temp
deletes the temp folder in the root folder.temp*
deletes any file or folder in the root folder with a name that begins with temp.**/temp/*
deletes all files and folders in any sub-folder named temp.**/temp*
deletes any file or folder with a name that begins with temp.!(*.vsix)
deletes all files in the root folder that do not have a .vsix extension.
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
RemoveSourceFolder
- Remove SourceFolder
boolean
. Default value: false
.
Attempts to remove the source folder after attempting to remove Contents
. If you want to remove the whole folder, set this to true
and set Contents
to *
.
:::moniker-end
:::moniker range=">=azure-pipelines-2022"
RemoveDotFiles
- Remove files starting with a dot
boolean
. Default value: false
.
Deletes files starting with a dot. For example: .git
and .dockerfile
. Omits these files if it's not specified explicitly. For example: /.*
. Learn more about minimatch.
:::moniker-end
All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.
:::moniker range="<=azure-pipelines"
None.
:::moniker-end
Use this task to delete files or folders from the agent working directory.
This example will delete some/file
, all files beginning with test
, and all files in all subdirectories called bin
.
steps:
- task: DeleteFiles@1
displayName: 'Remove unneeded files'
inputs:
contents: |
some/file
test*
**/bin/*
This example will delete some/one
, some/three
and some/four
but will leavesome/two
.
steps:
- task: DeleteFiles@1
displayName: 'Remove unneeded files'
inputs:
contents: |
some/!(two)
This example will delete some/one
and some/four
but will leave some/two
and some/three
.
steps:
- task: DeleteFiles@1
displayName: 'Remove unneeded files'
inputs:
contents: |
some/{one,four}
This example will delete all .txt
files. Files starting with a dot will be deleted as well.
steps:
- task: DeleteFiles@1
displayName: 'Remove unneeded files'
inputs:
contents: |
/some/*.txt
removeDotFiles: true
:::moniker range=">=azure-pipelines-2022"
Requirement | Description |
---|---|
Pipeline types | YAML, Classic build |
Runs on | Agent, DeploymentGroup |
Demands | None |
Capabilities | This task does not satisfy any demands for subsequent tasks in the job. |
Command restrictions | This task runs using the following command restrictions: restricted |
Settable variables | This task has permission to set the following variables: Setting variables is disabled |
Agent version | 2.182.1 or greater |
Task category | Utility |
:::moniker-end
:::moniker range="<=azure-pipelines-2020.1"
Requirement | Description |
---|---|
Pipeline types | YAML, Classic build |
Runs on | Agent, DeploymentGroup |
Demands | None |
Capabilities | This task does not satisfy any demands for subsequent tasks in the job. |
Command restrictions | Any |
Settable variables | Any |
Agent version | 1.92.0 or greater |
Task category | Utility |
:::moniker-end