Azure DevOps 仅存档来自构建删除的选定文件?

Vas*_*gas 3 azure-devops azure-pipelines

有没有办法在构建任务后只存档选定的文件?我只找到了“归档文件”任务,但它完全归档了整个文件夹。

Leo*_*SFT 5

Azure DevOps 仅存档来自构建删除的选定文件?

恐怕没有这样的开箱即用任务来存档选定的文件而不是文件夹。

大多数现有任务,如Archive filesZip and unzip directory build taskZip And Upload都是为文件夹而不是多个文件提供服务。

正如 Josh 评论的那样,最直接的方法是将多个文件复制到目录中并将它们压缩在一起,以避免使问题过于复杂。

但是如果这个问题对你很重要,你可以尝试使用 Powershell 任务来解决这个问题:

Write-Output 'Archive selected files And folders'

$compress = @{
Path= "$(Build.SourcesDirectory)\dist\test.txt", "$(Build.SourcesDirectory)\test2.txt"
CompressionLevel = "Fastest"
DestinationPath = "$(Build.ArtifactStagingDirectory)\Draft.Zip"
}
Compress-Archive @compress
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

然后我可以存档多个文件。

如果你想要多个文件夹,你可以使用如下命令:

Compress-Archive -Path C:\Reference -DestinationPath C:\Archives\Draft.zip
Run Code Online (Sandbox Code Playgroud)

检查文档压缩存档以获取更多详细信息。

希望这可以帮助。