Archive Files task
Azure Pipelines | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
Use this task 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.
Demands
None
YAML snippet
# 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
Arguments
Argument | Description |
---|---|
rootFolderOrFile Root folder or file to archive |
(Required) Enter the root folder or file path to add to the archive. If a folder, everything under the folder will be added to the resulting archive Default value: $(Build.BinariesDirectory) |
includeRootFolder Prepend root folder name to archive paths |
(Required) 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: /home/user/output/classes/ , and contains: com/acme/Main.class .
|
archiveType Archive type |
(Required) Specify the compression scheme used. To create foo.jar , for example, choose zip for the compression, and specify foo.jar as the archive file to create. For all tar files (including compressed ones), choose tar .
|
sevenZipCompression 7z compression |
Optionally choose a compression level, or choose None to create an uncompressed 7z file Default value: 5 |
tarCompression Tar compression |
Optionally choose a compression scheme, or choose None to create an uncompressed tar file.
Default value: gz |
archiveFile Archive file to create |
(Required) Specify the name of the archive file to create. For example, to create foo.tgz , select the tar archive type and gz for tar compression. Default value: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip |
replaceExistingArchive Replace existing archive |
(Required) 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:
|
verbose Forces verbose output |
(Optional) If set to true, forces tools to use verbose output. Overrides 'quiet'. Default value: false |
quiet Forces quiet output |
(Optional) If set to true, forces tools to use quiet output. Can be overridden by 'verbose'. Default value: false |
Open source
This task is open source on GitHub. Feedback and contributions are welcome.
FAQ
Q: I'm having issues with publishing my artifacts. How can I view the detailed logs?
To enable detailed logs for your pipeline:
- Edit your pipeline and select Variables
- Add a new variable with the name
System.Debug
and valuetrue
- 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.
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.