Archive Files task
Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
Use this task in a build or release pipeline to create an archive file from a source folder. A range of standard archive formats are supported including .zip, .jar, .war, .ear, .tar, .7z, and more.
# Archive files # Compress files into .7z, .tar.gz, or .zip - task: ArchiveFiles@2 inputs: #rootFolderOrFile: '$(Build.BinariesDirectory)' #includeRootFolder: true #archiveType: 'zip' # Options: zip, 7z, tar, wim #tarCompression: 'gz' # Optional. Options: gz, bz2, xz, none #archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' #replaceExistingArchive: true #verbose: # Optional #quiet: # Optional
|Root folder (or file) to archive||
The folder (or file) you wish to archive. The default file path is relative from the root folder of the repo (same as if you had specified
If the specified path is a folder, recursively, all nested files and folders will be included in the archive.
If the specified path is a file, only the single file will be included in the archive.
|Prefix root folder name to archive paths||If selected, the root folder name will be prefixed to file paths within the archive. Otherwise, all file paths will start one level lower.
For example, suppose the selected root folder is:
|Archive type||Specify the compression scheme used. To create
|Tar compression||Only applicable if the
Optionally choose a compression scheme, or choose
|Archive file to create||Specify the name of the archive file to create. The file extension should match the selected archive type. For example to create
|Replace existing archive||If an existing archive exists, specify whether to overwrite it. Otherwise, files will be added to it as long as it is not a compressed tar.
If adding to an existing archive, these types are supported:
This task is open source on GitHub. Feedback and contributions are welcome.
Q & A
Q: I'm having problems. How can I troubleshoot them?
A: Try this:
On the variables tab, add
system.debugand set it to
true. Select to allow at queue time.
In the explorer tab, view your completed build and click the build step to view its output.
The control options arguments described above can also be useful when you're trying to isolate a problem.
Q: How do variables work? What variables are available for me to use in the arguments?
$(Agent.BuildDirectory) are just a few of the variables you can use.
Variables are available in expressions as well as scripts; see variables to learn more about how to use them.
There are some predefined build and release variables you can also rely on.
Do I need an agent?
You need at least one agent to run your build or release. Get an agent for Linux, macOS, or Windows.
I'm having problems. How can I troubleshoot them?
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.