Azure DevOps 中的 Gzip 文件

Gzip file in Azure DevOps

我需要在 Azure DevOps 中以 gz 格式压缩 Js 文件。我已经使用 Azure 内置存档任务来 zip 文件,但只有 tar.gz 可用。我只想要gz。我需要 运行 的命令是

7z.exe a -tgzip $targetFile $sourceFile

有没有办法在 Azure DevOps 中做到这一点。

7zip 似乎是 hosted pipeline image 上配置的工具。您可以只创建一个 PowerShell 任务来包装您想要的调用。

使用 windows-2019 图片的示例 YML 片段:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: '& 7z.exe a -tgzip $(Build.StagingDirectory) $(Build.SourcesDirectory)\README.md'

任务日志:

Starting: PowerShell
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.170.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\a5e0fcab-474f-4462-9a92-36185caa17a8.ps1'"

7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21

Scanning the drive:
1 file, 985 bytes (1 KiB)

Creating archive: D:\a\a.gz

Add new data to archive: 1 file, 985 bytes (1 KiB)


Files read from disk: 1
Archive size: 562 bytes (1 KiB)
Everything is Ok
Finishing: PowerShell