Afnan Ashraf
Afnan Ashraf

Reputation: 316

Gzip file in Azure DevOps

I need to compress a Js file in Azure DevOps in gz format. I have use Azure built-in archive task to zip the file but there is only tar.gz available. I want only gz. Command which i need to run is

7z.exe a -tgzip $targetFile $sourceFile

Is there any way to do this in Azure DevOps.

Upvotes: 1

Views: 1376

Answers (1)

Matt
Matt

Reputation: 4065

7zip appears to be a tool configured on the hosted pipeline image. You can just create a PowerShell task that wraps the calls you want.

An example YML snippet using the windows-2019 image:

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

Log for the task:

Starting: PowerShell
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.170.1
Author       : Microsoft Corporation
Help         : https://learn.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\1\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

Upvotes: 1

Related Questions