Extract Files task

Azure Pipelines | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 | TFS 2017

Use this task to extract files from archives to a target folder using match patterns. A range of standard archive formats is supported, including .zip, .jar, .war, .ear, .tar, .7z, and more.



YAML snippet

# Extract files
# Extract a variety of archive and compression files such as .7z, .rar, .tar.gz, and .zip
- task: ExtractFiles@1
    #archiveFilePatterns: '**/*.zip' 
    #cleanDestinationFolder: true 
    #overwriteExistingFiles: false


Argument Description
Archive file patterns

Patterns to match the archives you want to extract. By default, patterns start in the root folder of the repo (same as if you had specified $(Build.SourcesDirectory)).

Specify pattern filters, one per line, that match the archives to extract. For example:

  • test.zip extracts the test.zip file in the root folder.
  • test/*.zip extracts all .zip files in the test folder.
  • **/*.tar extracts all .tar files in the root folder and sub-folders.
  • **/bin/*.7z extracts all ''.7z'' files in any sub-folder named bin.

The pattern is used to match only archive file paths, not folder paths, and not archive contents to be extracted. So you should specify patterns such as **/bin/** instead of **/bin.

Destination folder Folder where the archives will be extracted. The default file path is relative to the root folder of the repo (same as if you had specified $(Build.SourcesDirectory)).
Clean destination folder before extracting Select this check box to delete all existing files in the destination folder before beginning to extract archives.
Overwrite files in the destination directory Select this option to overwrite files in the output directory if they already exist.
Path to 7z utility You can specify custom path to 7z utility using this option. If it's not specified on Windows - default 7zip version supplied with a task will be used.
Control options


Extract all .zip files recursively

This example will extract all .zip files recursively, including both root files and files from sub-folders

- task: ExtractFiles@1
    archiveFilePatterns: '**/*.zip'
    cleanDestinationFolder: true
    overwriteExistingFiles: false

Extract all .zip files from subfolder

This example will extract test/one.zip, test/two.zip but will leave test/nested/three.zip.

- task: ExtractFiles@1
    archiveFilePatterns: 'test/*.zip'
    cleanDestinationFolder: true
    overwriteExistingFiles: false

Open source

This task is open source on GitHub. Feedback and contributions are welcome.


Where can I learn more about file matching patterns?

File matching patterns reference

Q: I'm having issues with publishing my artifacts. How can I view the detailed logs?

To enable detailed logs for your pipeline:

  1. Edit your pipeline and select Variables
  2. Add a new variable with the name System.Debug and value true
  3. Save

Q: Which variables are available to me?

A: $(Build.SourcesDirectory) and $(Agent.BuildDirectory) are just few of the variables you can use in your pipeline. Variables are available as expressions or scripts.

See Define variables, predefined variables, and Classic release and artifacts variables to learn about the different types of variables.

Do I need an agent?

You need at least one agent to run your build or release.

I'm having problems. How can I troubleshoot them?

See Troubleshoot Build and Release.

I can't select a default agent pool and I can't queue my build or release. How do I fix this?

See Agent pools.

My NuGet push task is failing with the following error: "Error: unable to get local issuer certificate". How can I fix this?

This can be fixed by adding a trusted root certificate. You can either add the NODE_EXTRA_CA_CERTS=file environment variable to your build agent, or you can add the NODE.EXTRA.CA.CERTS=file task variable in your pipeline. See Node.js documentation for more details about this variable. See Set variables in a pipeline for instructions on setting a variable in your pipeline.

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.