【问题标题】:Azure devops pipeline ArchiveFiles error: Unable to locate executable file: 'zip'Azure devops 管道 ArchiveFiles 错误:无法找到可执行文件:'zip'
【发布时间】:2023-04-07 04:07:01
【问题描述】:

我正在为 python 包构建创建 Azure DevOps 管道,但任务 ArchiveFiles@2 失败。

- 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

错误日志是这样的

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.

【问题讨论】:

  • 您好,刚刚检查一下这个问题现在是否仍然阻碍您?这个问题有更新吗?
  • 是的,我仍然有这个问题。根据我得到的答案,它应该适用于 Ubuntu 最新版本,但我不确定为什么它在我的情况下不起作用。
  • 嗨@CPP_atheitia,你能检查一下你的组织区域,然后在这里分享吗?另外,能否尝试创建另一个区域组织并再次测试?
  • @Carlos hi,该地区是西欧

标签: python azure-devops


【解决方案1】:

我同意@Daniel Mann 的观点,并且在执行 ArchiveFiles@2 任务时遇到了同样的问题。我将 ubuntu 18.04 版本的代理用于 DevOps 代理池。安装 ZIP 后它就可以工作了。

【讨论】:

  • 安装 zip 为我完成了这项工作
【解决方案2】:

代理上没有安装zip 命令。您需要确保已安装 zip 软件包。即sudo apt-get -y install zip

【讨论】:

    【解决方案3】:

    代理 ubuntu-latest 是 Ubuntu20.04,它安装了zip 3.07-Zip 16.02,我们可以查看这个doc 了解更多详情。

    你可以试试这个yaml,我测试过,它可以工作。

    YAML 定义:

    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
    

    结果:

    【讨论】:

      【解决方案4】:

      尝试使用 7z 生成一个 zip 文件。以下适用于我们在 ubuntu 上:

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

      【讨论】:

        猜你喜欢
        • 2021-06-14
        • 2022-01-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-04
        • 2020-05-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多