#azure-devops
Вопрос:
Я копирую то, что хочу, в $(Build.ArtifactStagingDirectory)
Например
# 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)'
а затем я копирую $(Build.ArtifactStagingDirectory)
в общий сетевой ресурс, как это:
- 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.
В сети я получаю новую папку для каждой сборки, и внутри нее находится все, что я ожидал. Очень хорошо, молодец Лазурный.
Я хотел бы превратить его в zip-файл, потому что мне нужно скопировать его в две чрезвычайно медленные сети.
Так:
- 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)'
Но содержимое 7z отличается от папки на \BLD
! Что происходит?
Еще более странно, если вместо rootFolderOrFile: $(Build.ArtifactStagingDirectory)
этого я поставлю
rootFolderOrFile: '$(publishBuildArtifactsTargetPathBase)$(publishBuildArtifactsSubfolder)$(name)'
тогда zip по-прежнему содержит неправильные файлы.
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!
Я заметил , что в Get-ChildItem
значении $(Build.ArtifactStagingDirectory)
, по-видимому, есть C:agent_work12a
, но в задаче zip его значение равно C:agent_work12b
.
Обновление: вывод журнала
Обратите внимание, что $(Build.ArtifactStagingDirectory)
это C:agent_work12b
вместо C:agent_work12a
(это есть a
во всех других задачах как до, так и после этой задачи).
##[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_work12s ##[debug]rootFolder=C:agent_work12b ##[debug]makeAbsolute:C:agent_work12b ##[debug]includeRootFolder=false ##[debug]archiveType=7z ##[debug]archiveFile=C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug]replaceExistingArchive=true ##[debug]repoRoot: C:agent_work12s ##[debug]win: Win ##[debug]check path : C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.0task.json ##[debug]set resource file to: C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.0task.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_work12s ##[debug]Creating archive with 7-zip: C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: a ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: -t7z ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: the-thing-app ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.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_work12s ##[debug]rootFolder=C:agent_work12b ##[debug]makeAbsolute:C:agent_work12b ##[debug]includeRootFolder=false ##[debug]archiveType=7z ##[debug]archiveFile=C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug]replaceExistingArchive=true ##[debug]repoRoot: C:agent_work12s ##[debug]win: Win ##[debug]check path : C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.0task.json ##[debug]set resource file to: C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.0task.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_work12s ##[debug]Creating archive with 7-zip: C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: a ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: -t7z ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: the-thing-app ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: TheThing.App ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: TheThing.BootstrapJson ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: TheThing.Service ##[debug]cwd (exclude root folder)= C:agent_work12b ##[debug]exec tool: C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe ##[debug]Arguments: ##[debug] a ##[debug] -t7z ##[debug] C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug] the-thing-app ##[debug] TheThing.App ##[debug] TheThing.BootstrapJson ##[debug] TheThing.Service [command]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe a -t7z C:agent_work12sTheThing_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_work12sTheThing_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_work12sTheThing_test-1.0.0.14179.7z ##[section]Finishing: Compress output.Privacy.App ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: TheThing.BootstrapJson ##[debug]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe arg: TheThing.Service ##[debug]cwd (exclude root folder)= C:agent_work12b ##[debug]exec tool: C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe ##[debug]Arguments: ##[debug] a ##[debug] -t7z ##[debug] C:agent_work12sTheThing_test-1.0.0.14179.7z ##[debug] the-thing-app ##[debug] TheThing.App ##[debug] TheThing.BootstrapJson ##[debug] TheThing.Service [command]C:agent_work_tasksArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b01.119.07zip7z.exe a -t7z C:agent_work12sTheThing_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_work12sTheThing_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_work12sTheThing_test-1.0.0.14179.7z ##[section]Finishing: Compress output
Комментарии:
1. попробуйте запустить задачу архивирования с
verbose: true
помощью , посмотрите, что происходит