微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CircleCI“无法确保工作区目录存在”

如何解决CircleCI“无法确保工作区目录存在”

我正在使用 CircleCI 来构建一个 Unity 项目。构建有效,但我试图利用 github-release orb 在 GitHub 上为构建创建一个发布。我为此创建了一个新的单独作业,因此我需要在作业之间共享数据。我正在使用 persist_to_workspace 来执行此操作,如文档中所述,但该解决方案似乎不起作用 - 我收到以下错误:“无法确保工作区目录 /root/project/Zipped 存在”。>

对于工作区持久化逻辑,我在 config.yml 文件添加了以下代码行:

  • working_directory: /root/project - 主要工作的执行者内部
  • persist_to_workspace - 作为我主要工作步骤中的最后一个命令
  • attach_workspace - 作为我第二份工作步骤中的开始命令

这是我的完整 config.yml 文件

orbs:
  github-release: h-matsuo/github-release@0.1.3

executors:
  unity_exec:
    docker:
      - image: unityci/editor:ubuntu-2019.4.19f1-windows-mono-0.9.0
    environment:
      BUILD_NAME: speedrun-circleci-build
    working_directory: /root/project

.build: &build
  executor: unity_exec
  steps:
    - checkout
    - run: mkdir -p /root/project/Zipped
    - run:
        name: Git submodule recursive
        command: git submodule update --init --recursive
    - run:
        name: Remove editor folder in shared project
        command: rm -rf ./Assets/Shared/Movement/Generic/Attributes/Editor/
    - run: 
        name: Converting Unity license
        command: chmod +x ./ci/unity_license.sh && ./ci/unity_license.sh
    - run:
        name: Building game binaries
        command: chmod +x ./ci/build.sh && ./ci/build.sh
    - run: 
        name: Zipping build
        command: apt update && apt -y install zip && zip -r "/root/project/Zipped/build.zip" ./Builds/
    - store_artifacts:
        path: /root/project/Zipped/build.zip
    - run:
        name: Show all files
        command: find "$(pwd)"
    - persist_to_workspace:
        root: Zipped
        paths:
            - build.zip
jobs:
  build_windows:
    <<: *build
    environment:
      BUILD_TARGET: StandaloneWindows64
  release:
    description: Build project and publish a new release tagged `v1.1.1`.
    executor: github-release/default
    steps:
      - attach_workspace:
          at: /root/project/Zipped
      - run:
          name: Show all files
          command: sudo find "/root/project"
      - github-release/create:
          tag: v1.1.1
          title: Version v1.1.1
          description: This release is version v1.1.1.
          file-path: ./build.zip
          
workflows:
  version: 2
  build:
    jobs:
      - build_windows
      - release:
          requires:
            - build_windows

有人可以帮我吗?

解决方法

如果有人遇到同样的问题,请尽量避免使用 /root 路径。我已将工件存储在 /tmp/ 内的某处,并且在存储工件之前,我已使用 mkdir-m 标志手动创建了带有 chmod 777 的文件夹,以指定 chmod 权限。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。