Atheitia
Atheitia

Reputation: 71

Azure devops pipeline ArchiveFiles error: Unable to locate executable file: 'zip'

I'm creating an Azure DevOps pipeline for python package build, but the task ArchiveFiles@2 failed.

- stage: Build
  jobs:
    - job: BuildApp
      pool:
        vmImage: 'ubuntu-latest'
      - task: ArchiveFiles@2
        inputs:
          rootFolderOrFile: '$(Build.SourcesDirectory)'
          includeRootFolder: false
          archiveType: 'zip'
          archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
          replaceExistingArchive: true
          verbose: true

The error log is this

Found 20 files
Archiving file: .env_sample
... 21 more ...

##[debug]Checking for archive destination folder:/__w/1/a
##[debug]Creating archive with zip: /__w/1/a/1009007.zip
##[debug]which 'zip'
##[debug]not found
##[debug]Unable to locate executable file: 'zip'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

Upvotes: 7

Views: 13546

Answers (3)

GaTechThomas
GaTechThomas

Reputation: 6075

Try using 7z to produce a zip file. The following works for us on ubuntu:

    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(APP_DIST_DIR)'
        includeRootFolder: false
        archiveType: '7z'
        archiveFile: '$(APP_DIST_DIR)/myfilename.zip'
        replaceExistingArchive: true

Upvotes: 0

Carlos
Carlos

Reputation: 126

The agent ubuntu-latest is Ubuntu20.04, it has install zip 3.0 and 7-Zip 16.02, we could check this doc for more details.

You could try this yaml, I tested it and it works.

YAML definition:

trigger: none
stages:
  - stage: Build
    jobs:
      - job: BuildApp
        pool:
          vmImage: 'ubuntu-latest'
        steps:
        - task: ArchiveFiles@2
          inputs:
            rootFolderOrFile: '$(Build.SourcesDirectory)'
            includeRootFolder: false
            archiveType: 'zip'
            archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
            replaceExistingArchive: true
            verbose: true

Result:

enter image description here

Upvotes: 0

Daniel Mann
Daniel Mann

Reputation: 59016

The agent doesn't have the zip command installed on it. You'll need to make sure the zip package is installed. i.e. sudo apt-get -y install zip

Upvotes: 8

Related Questions