使用CodeBuild的自动构建在AWS上不起作用

问题描述 投票:0回答:1

我正在尝试使用我的MERN堆栈网络应用程序自动化构建过程。

当前,我使用CodePipeline,其中:

  1. 从GitHub作为源获取我的代码
  2. 使用CodeBuild(Ubuntu 2.0)运行构建
  3. 并将其部署到我的Elastic BeanStalk环境。

第1步和第3步以前曾经做得很好,但是在进行最终的git push之前,我总是必须运行我的构建,这使将所有构建文件包含在Code Review中变得很烦人。

尝试使用CodeBuild后,即使客户端似乎根据日志构建的很好,前端似乎也没有更新。

以下是成功构建日志的摘录:enter image description here这是我的buildspec.yml文件的样子:

version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 10
  pre_build:
    commands:
      - echo "Entered pre-build phase"
  build:
    commands:
      - echo "Entered build phase"
      - yarn global add react-scripts
      - cd client && yarn install
      - yarn run build
  post_build:
    commands:
      - echo "Entered post-build phase"

这里是我的CodeBuild项目的其他一些设置:

  1. 来源:GitHub
  2. 环境:Ubuntu 2.0(最新)
  3. BuildSpec:使用文件(上面列出)
  4. 工件:没有工件(我还检查了Allow AWS CodeBuild to modify this service role so it can be used with this build project作为服务角色权限)
  5. 日志:使用CloudLogs

enter image description here

任何帮助将不胜感激!预先感谢。

node.js amazon-web-services aws-codepipeline aws-codebuild
1个回答
0
投票

您的buildspec中没有'artifacts'部分,这是将构建文件导出到下一阶段(要部署到Elastic Beanstalk的文件)所必需的。最后在您的buildspec中添加以下内容:

artifacts:
  files:
    - '**/*'
  base-directory: ./client/build

((假设您的构建文件位于构建目录的根目录中,如果不是,请进行调整。)

© www.soinside.com 2019 - 2024. All rights reserved.