如何修复 AWS code-build apt-get update exit status 100 以便 React 应用程序上传到 s3

Dha*_*val 7 amazon-web-services aws-codebuild

我有 ReactJs 应用程序并使用 AWS s3 部署静态站点。我已经为 CI/CD 设置了 AWS 代码构建。我正在使用 bitbucket,当任何 PR 合并到 master 分支 Web-hook 出现时,都会触发 React 应用程序构建并在 s3 上上传构建。

它在过去两年中运行良好,但在上次构建中我遇到了以下错误。

W:GPG 错误:https://dl.yarnpkg.com/debian stable InRelease:以下签名无效:EXPKEYSIG 23E7166788B63E1E Yarn Packaging yarn@dan.cx E:存储库“https://dl.yarnpkg.com/debian” stable InRelease' 未签名。

[容器] 2021/02/04 07:39:02 命令未成功退出 apt-get update exit status 100 [容器] 2021/02/04 07:39:02 阶段完成:安装状态:失败 [容器] 2021/ 02/04 07:39:02 阶段上下文状态代码:COMMAND_EXECUTION_ERROR 消息:执行命令时出错:apt-get update。原因:退出状态100

这是完整的日志输出。

在此输入图像描述

这是buildspec.yml文件

# aws codebuild for React and deployment to S3
version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 10
    commands:
      - echo Installing build dependencies...
      - apt-get update
      - apt-get install -y sshpass zip unzip
  pre_build:
    commands:
      - echo Build started on `date`
      - echo Installing source NPM dependencies...
      - npm ci
      - cp src/gatsby-overrides/gatsby-sharp.js node_modules/gatsby-plugin-sharp/index.js
      - cp src/gatsby-overrides/gatsby-image.js node_modules/gatsby-image/index.js
  build:
    commands:
      - npm run build
      - chmod u+x script.sh
      - ./script.sh
    finally:
      - echo Build completed on `date`
cache:
  paths:
    - 'public/**/*'
Run Code Online (Sandbox Code Playgroud)

pet*_*rch 8

它在第 82 行抱怨签名密钥,当你在 apt update 之前安装它时会发生什么?就像这里建议的那样:https://github.com/yarnpkg/yarn/issues/7866

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
Run Code Online (Sandbox Code Playgroud)

  • 尝试不使用 sudo。顺便说一句,这是一个 ubuntu 特定问题,与代码构建无关。 (2认同)