AWS Codecommit 忽略环境变量

AWS Codecommit Ignores environment variables

我正在尝试通过 AWS CodePipeline 部署练习应用程序。但是,当我构建时,我注意到我添加到 buildspec.yml 文件的环境变量没有被我的 React 应用程序获取。

我的构建规范文件低于

version: 0.1

env:
  variables:
    REACT_APP_TEST: "If you're seeing this text, the variable worked! Yay! ^o~"

phases:
  install:
    commands:      
      - echo Installing dependencies...
      - npm i
  pre_build:
    commands:
      - echo Nothing to see in prebuld move along! :P
  build:
    commands:
      - echo Build started on `date`
      - npm run build
  post_build:
    commands:
      - echo Build completed on `date`

artifacts:
  files:
    - '**/*'

上面的变量是在一个简单的 div 中使用 process.env.REACT_APP_TEST 引用的 According to the docs I should be able to specify environment variables,但是当我部署它时,文本没有显示在我的应用程序上。我错过了什么吗?

请使用 buildspec 版本 0.2。没有理由再使用 0.1 版本了。只需更改 "version: 0.1" > "version: 0.2".

构建规范 0.1 具有 "environment_variables" > "plaintext" 而不是 "env" > "variables"。但是,我们强烈建议您切换到 0.2 版本,这是获得最新功能的最新版本。