Partager via


Extract Files task

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.

Demands

None

Arguments

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.

Default value: **/*.zip

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.

Default value: true

Overwrite files in the destination directory

Select this option to overwrite files in the output directory if they already exist. If the option is false, the script prompts on existing files, asking whether you want to overwrite them.

Default value: false

Path to 7z utility (Optional) 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.

Task control options

Examples

Extract all .zip files recursively

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

steps:
- task: ExtractFiles@1
  inputs:
    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.

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

Open source

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

FAQ

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.

Q: Task allows me to publish artifacts in deployment job in yaml pipeline, but I am not able to use it in downstream pipeline?

A: Deployment jobs do not have the context of source branches and are hence not appropriate for publishing artifacts. They have been primarily designed to consume artifacts. A workaround would be to isolate that logic into a separate job (with dependencies on your deployment jobs).

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.