使用AWS CodeBuild构建角度项目

ujj*_*arg 3 continuous-integration node.js aws-codecommit aws-codepipeline aws-codebuild

我们有一个Angular项目,我们正在尝试使用AWS CodePipeline来部署项目.

我们已将项目推送到CodeCommit存储库.

现在,我们面临着使用AWS CodeBuild生成构建的挑战.在CodeBuild中,构建定义是

phases:
  build:
    commands:
      - npm install && ng build-prod
Run Code Online (Sandbox Code Playgroud)

我们收到错误 ng: not found

我们还尝试了以下构建定义:

phases:
      build:
        commands:
          - npm install && run build-prod
Run Code Online (Sandbox Code Playgroud)

我们得到的错误是 run: not found

此外,我们不确定我们必须在"输出文件"字段中输入什么.

请帮忙..!!

小智 10

CodeBuild的Node.js容器没有安装angular-cli.Just Node.js和npm.在构建项目之前,必须安装angular-cli.上面有一个buildspec.yml示例,用于在S3存储桶中部署角度项目:

version: 0.2
env:
    variables:
        CACHE_CONTROL: "86400"
        S3_BUCKET: {-INSERT BUCKET NAME FOR STATIC WEBSITE HERE-}
        BUILD_FOLDER: {-INSERT THE NAME OF THE BUILD FOLDER HERE-}
        BUILD_ENV: "prod"
phases:
    install:
        commands:
            - echo Installing source NPM dependencies...
            - npm install
            - npm install -g @angular/cli
    build:
        commands:
            - echo Build started on `date`
            - ng build --${BUILD_ENV}
    post_build:
         commands:
            - aws s3 cp ${BUILD_FOLDER} s3://${S3_BUCKET} --recursive --acl public-read --cache-control "max-age=${CACHE_CONTROL}"
            - echo Build completed on `date`
artifacts:
    files:
        - '**/*'
    base-directory: 'dist*'
    discard-paths: yes
Run Code Online (Sandbox Code Playgroud)


小智 0

您的 npm 安装似乎有问题。参考: https: //www.npmjs.com/package/angular-cli

输出文件应该是您想要上传到工件 s3 存储桶的文件,例如:appspec.yml、target/my-app.jar。您可以查看我们文档中的 Artifact 部分:https://docs.aws.amazon.com/codebuild/latest/userguide/create-project.html ?icmpid =docs_acb_console#create-project-console 谢谢 Xin