I copy the things I want into $(Build.ArtifactStagingDirectory)
For example
# This matches SetupSecurity.sql but omits Setup.sql
# Therefore Setup.sql was renamed to SetupSchema.sql.
- task: CopyFiles@2
condition: eq(variables.publishDeployables, true)
displayName: 'Add SQL to output'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: 'Setup*.sql'
targetFolder: '$(Build.ArtifactStagingDirectory)'
and then I copy $(Build.ArtifactStagingDirectory)to a network share like this:
- task: PublishBuildArtifacts@1
condition: eq(variables.publishDeployables, true)
displayName: 'Copy ArtifactStagingDirectory to \\BLD'
inputs:
ArtifactName: $(name)
PathtoPublish: '$(Build.ArtifactStagingDirectory)\'
publishLocation: 'FilePath'
TargetPath: '$(publishBuildArtifactsTargetPathBase)\$(publishBuildArtifactsSubfolder)'
#zipAfterPublish: true Doesn't do anything.
On the network shere I get a new folder for each build, and inside it is all of the stuff I was expecting. Very good; well done Azure.
I'd like to make it into a zip file because I have to copy it across two excpetionally slow networks.
So:
- task: ArchiveFiles@1
condition: eq(variables.publishDeployables, true)
displayName: 'Compress output'
inputs:
rootFolderOrFile: $(Build.ArtifactStagingDirectory)
includeRootFolder: true
archiveType: 7z
sevenZipCompression: ultra
archiveFile: '$(name).7z'
replaceExistingArchive: true
- task: CopyFiles@2
condition: eq(variables.publishDeployables, true)
displayName: 'Copy zip to \\BLD'
inputs:
contents: '$(name).7z'
targetFolder: '$(publishBuildArtifactsTargetPathBase)\$(publishBuildArtifactsSubfolder)\'
But the contents of the 7z are different to the folder on \\BLD!
What's going on?
Even more bizarre, if instead of rootFolderOrFile: $(Build.ArtifactStagingDirectory) I set
rootFolderOrFile: '$(publishBuildArtifactsTargetPathBase)\$(publishBuildArtifactsSubfolder)\$(name)'
then the zip still contains the wrong files.
So I added a task to print out what is in $(Build.ArtifactStagingDirectory)
- task: PowerShell@2
displayName: Show contents of ArtifactStagingDirectory
inputs:
targetType: 'inline'
script: Get-ChildItem -Directory $(Build.ArtifactStagingDirectory) | Select-Object FullName
And that is indeed what ends up on \\BLD, but again is not what ends up in the zip!
I noticed that in the Get-ChildItem the value of $(Build.ArtifactStagingDirectory) appears to be C:\agent\_work\12\a, but in the zip task the value of it is C:\agent\_work\12\b.
Update: log output
Notice that $(Build.ArtifactStagingDirectory) is C:\agent\_work\12\b instead of C:\agent\_work\12\a (it is a in all other tasks both before and after this task).
##[section]Starting: Compress output
==============================================================================
Task : Archive Files
Description : Archive files using compression formats such as .7z, .rar, .tar.gz, and .zip.
Version : 1.119.0
Author : Microsoft Corporation
Help : [More Information](http://go.microsoft.com/fwlink/?LinkId=809083)
==============================================================================
##[debug]agent.workFolder=C:\agent\_work
##[debug]loading inputs and endpoints
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading INPUT_ARCHIVEFILE
##[debug]loading INPUT_ARCHIVETYPE
##[debug]loading INPUT_INCLUDEROOTFOLDER
##[debug]loading INPUT_REPLACEEXISTINGARCHIVE
##[debug]loading INPUT_ROOTFOLDER
##[debug]loading INPUT_ROOTFOLDERORFILE
##[debug]loading INPUT_SEVENZIPCOMPRESSION
##[debug]loading INPUT_TARCOMPRESSION
##[debug]loading INPUT_VERBOSE
##[debug]loading SECRET_CHECKMARX_PASSWORD
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 14
##[debug]System.DefaultWorkingDirectory=C:\agent\_work\12\s
##[debug]rootFolder=C:\agent\_work\12\b
##[debug]makeAbsolute:C:\agent\_work\12\b
##[debug]includeRootFolder=false
##[debug]archiveType=7z
##[debug]archiveFile=C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug]replaceExistingArchive=true
##[debug]repoRoot: C:\agent\_work\12\s
##[debug]win: Win
##[debug]check path : C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\task.json
##[debug]set resource file to: C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\task.json
##[debug]system.culture=en-US
##[debug]Found: 4 files to archive:
##[debug]the-thing-app
##[debug]TheThing.App
##[debug]TheThing.BootstrapJson
##[debug]TheThing.Service
##[debug]Checking for archive destination folder:C:\agent\_work\12\s
##[debug]Creating archive with 7-zip: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: a
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: -t7z
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: the-thing-app
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: Playtech.##[section]Starting: Compress output
==============================================================================
Task : Archive Files
Description : Archive files using compression formats such as .7z, .rar, .tar.gz, and .zip.
Version : 1.119.0
Author : Microsoft Corporation
Help : [More Information](http://go.microsoft.com/fwlink/?LinkId=809083)
==============================================================================
##[debug]agent.workFolder=C:\agent\_work
##[debug]loading inputs and endpoints
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading INPUT_ARCHIVEFILE
##[debug]loading INPUT_ARCHIVETYPE
##[debug]loading INPUT_INCLUDEROOTFOLDER
##[debug]loading INPUT_REPLACEEXISTINGARCHIVE
##[debug]loading INPUT_ROOTFOLDER
##[debug]loading INPUT_ROOTFOLDERORFILE
##[debug]loading INPUT_SEVENZIPCOMPRESSION
##[debug]loading INPUT_TARCOMPRESSION
##[debug]loading INPUT_VERBOSE
##[debug]loading SECRET_CHECKMARX_PASSWORD
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 14
##[debug]System.DefaultWorkingDirectory=C:\agent\_work\12\s
##[debug]rootFolder=C:\agent\_work\12\b
##[debug]makeAbsolute:C:\agent\_work\12\b
##[debug]includeRootFolder=false
##[debug]archiveType=7z
##[debug]archiveFile=C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug]replaceExistingArchive=true
##[debug]repoRoot: C:\agent\_work\12\s
##[debug]win: Win
##[debug]check path : C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\task.json
##[debug]set resource file to: C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\task.json
##[debug]system.culture=en-US
##[debug]Found: 4 files to archive:
##[debug]the-thing-app
##[debug]TheThing.App
##[debug]TheThing.BootstrapJson
##[debug]TheThing.Service
##[debug]Checking for archive destination folder:C:\agent\_work\12\s
##[debug]Creating archive with 7-zip: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: a
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: -t7z
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: the-thing-app
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: TheThing.App
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: TheThing.BootstrapJson
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: TheThing.Service
##[debug]cwd (exclude root folder)= C:\agent\_work\12\b
##[debug]exec tool: C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe
##[debug]Arguments:
##[debug] a
##[debug] -t7z
##[debug] C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug] the-thing-app
##[debug] TheThing.App
##[debug] TheThing.BootstrapJson
##[debug] TheThing.Service
[command]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe a -t7z C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z the-thing-app TheThing.App TheThing.BootstrapJson TheThing.Service
7-Zip [64] 16.00 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-10
Scanning the drive:
79 folders, 1079 files, 344812308 bytes (329 MiB)
Creating archive: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
Items to compress: 1158
Files read from disk: 1079
Archive size: 61843313 bytes (59 MiB)
Everything is Ok
##[debug]task result: Succeeded
##[debug]Processed: ##vso[task.complete result=Succeeded;]Successfully created archive: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[section]Finishing: Compress output.Privacy.App
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: TheThing.BootstrapJson
##[debug]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe arg: TheThing.Service
##[debug]cwd (exclude root folder)= C:\agent\_work\12\b
##[debug]exec tool: C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe
##[debug]Arguments:
##[debug] a
##[debug] -t7z
##[debug] C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[debug] the-thing-app
##[debug] TheThing.App
##[debug] TheThing.BootstrapJson
##[debug] TheThing.Service
[command]C:\agent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\1.119.0\7zip\7z.exe a -t7z C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z the-thing-app TheThing.App TheThing.BootstrapJson TheThing.Service
7-Zip [64] 16.00 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-10
Scanning the drive:
79 folders, 1079 files, 344812308 bytes (329 MiB)
Creating archive: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
Items to compress: 1158
Files read from disk: 1079
Archive size: 61843313 bytes (59 MiB)
Everything is Ok
##[debug]task result: Succeeded
##[debug]Processed: ##vso[task.complete result=Succeeded;]Successfully created archive: C:\agent\_work\12\s\TheThing_test-1.0.0.14179.7z
##[section]Finishing: Compress output