microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.49k stars 2.61k forks source link

Archive@2 task fails on a Linux agent with message Failed which: Not found zip: null #9111

Closed BiribiriJaNai closed 5 years ago

BiribiriJaNai commented 5 years ago

Environment

Issue Description

using this config in my Yaml pipeline,

# create zip
- task: ArchiveFiles@2
  displayName: 'Archive $(build.sourceBranchName)'
  inputs:
    rootFolderOrFile: './_build/Tasks/$(build.sourceBranchName)'
    archiveFile: '$(build.artifactStagingDirectory)/$(build.sourceBranchName).zip'
    archiveType: zip
    includeRootFolder: false
    replaceExistingArchive: true

the task fails with the message Failed which: Not found zip: null

Task logs

2018-12-18T10:51:41.4507586Z ==============================================================================
2018-12-18T10:51:41.4507660Z Task         : Archive Files
2018-12-18T10:51:41.4507760Z Description  : Archive files using compression formats such as .7z, .rar, .tar.gz, and .zip.
2018-12-18T10:51:41.4507817Z Version      : 2.127.2
2018-12-18T10:51:41.4507867Z Author       : Microsoft Corporation
2018-12-18T10:51:41.4507980Z Help         : [More Information](http://go.microsoft.com/fwlink/?LinkId=809083)
2018-12-18T10:51:41.4508038Z ==============================================================================
2018-12-18T10:51:41.5936892Z Error: Failed which: Not found zip: null
2018-12-18T10:51:41.5939418Z ##[error]Failed which: Not found zip: null

Edit: The task does work properly on a Windows agent.

2018-12-18T11:54:26.0786130Z ==============================================================================
2018-12-18T11:54:26.0786218Z Task         : Archive Files
2018-12-18T11:54:26.0786464Z Description  : Archive files using compression formats such as .7z, .rar, .tar.gz, and .zip.
2018-12-18T11:54:26.0786567Z Version      : 2.127.2
2018-12-18T11:54:26.0786778Z Author       : Microsoft Corporation
2018-12-18T11:54:26.0786857Z Help         : [More Information](http://go.microsoft.com/fwlink/?LinkId=809083)
2018-12-18T11:54:26.0786919Z ==============================================================================
2018-12-18T11:54:26.8586040Z [command]C:\agents\01\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\2.127.2\7zip\7z.exe a -tzip C:\agents\01\_work\6\a\WacV0.zip icon.png interfaces.js node_modules package.json Strings task.json task.loc.json taskoptions.js wac.js wacapi.js wacoptions.js
2018-12-18T11:54:38.9366002Z 
2018-12-18T11:54:38.9368233Z 7-Zip [64] 16.00 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-10
2018-12-18T11:54:38.9517458Z 
2018-12-18T11:54:38.9563023Z Scanning the drive:
2018-12-18T11:54:38.9563381Z 182 folders, 2005 files, 10647759 bytes (11 MiB)
2018-12-18T11:54:38.9563563Z 
2018-12-18T11:54:38.9563768Z Creating archive: C:\agents\01\_work\6\a\WacV0.zip
2018-12-18T11:54:38.9564181Z 
2018-12-18T11:54:38.9564356Z Items to compress: 2187
2018-12-18T11:54:38.9564500Z 
2018-12-18T11:54:38.9564634Z 
2018-12-18T11:54:38.9564817Z Files read from disk: 2005
2018-12-18T11:54:38.9564987Z Archive size: 2745191 bytes (2681 KiB)
2018-12-18T11:54:38.9565472Z Everything is Ok
ovenal commented 5 years ago

I have the same problem.

BiribiriJaNai commented 5 years ago

I know why the task fails and I should have looked at the source code first. When the task runs on Windows, there's no problem because you're shipping 7zip.exe with the task. On the other hand, when running on Linux, you're assuming that zip is already installed on the OS, which is not the case on a freshly installed VM... A simple sudo apt-get install zip solved the problem in my case, but do you plan to address this?

bryanmacfarlane commented 5 years ago

Tasks are tool runners and prefer to run tools brought by the system or container. The only reason we added 7z to win is it’s not on most systems likes Linux and there’s not an easy cmd like apt-get to get it.

BiribiriJaNai commented 5 years ago

@bryanmacfarlane , thanks for your prompt answer. I agree, tasks should be tool runners. But instead of failing, could we use a capability-demand-like system to alert the user that the task he's using may need an external tool? Either way, I don't mind installing these tools beforehand.

PatrickQuintal commented 5 years ago

I just ran into this same exact issue. Thank the computer gods for @BiribiriJaNai for having a look.

I want to echo the request of at least print some helpful information if zip is missing

A very light & minimal VM (which we should strive to do on build machines) will most likely not contain numerous tools. At least making the error message more "friendly" would be great.

Danxx26hub commented 2 years ago

I ran into this today, I was able to install zip utility using apt-get. it would be nice to have this included as part of an extension maybe?