【问题标题】:Codebuild is unable to find build directoryCodebuild 找不到构建目录
【发布时间】:2021-03-20 13:53:07
【问题描述】:

我正在运行我的 buildspec.yml,在 npm run build 命令之后它应该在根路径中创建构建目录,但是,codebuild 无法找到构建目录。我已经从资源中尝试了所有可能的方法,但我仍然我无法解决“找不到匹配的构建基目录路径”

PS:我使用 codecommit 作为源代码,使用 codebuild & codepipeline 来运行部署步骤,并使用 S3 存储桶来部署构建目录。

我的 buildspec.yml

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 10
  pre_build:
    commands:
      - echo Installing dependencies...
      - npm cache clean --force
      - npm install
      - npm --version
  
  build:
    commands:  
      - aws s3 rm s3://bucketname --recursive        
      
  post_build:
    commands:
           - pwd
           - cd src
           - npm run build
           - ls -la
           - aws s3 sync build s3://bucketname
       
artifacts:
  files:
        - "**/*"

【问题讨论】:

  • 您可以使用一个 S3 命令来满足您的要求 aws s3 sync ./build/ s3://bucketname/ --delete 没有更多的调试/日志或脚本失败的地方,我只能猜测是这一行 cd src 导致了您的问题。
  • @GeorgeRushby 是的,cd src 引起了这个问题,我删除了它,它就像一个魅力一样,谢谢。

标签: node.js amazon-web-services xcodebuild aws-codepipeline aws-codecommit


【解决方案1】:

我不得不从 post_build 阶段删除 cd src,因为我的构建然后它与管道一起工作,没有任何错误。

【讨论】:

    猜你喜欢
    • 2021-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 2019-05-17
    • 2020-03-15
    相关资源
    最近更新 更多