AWS代码构建,代码部署,CI / CD管道错误

时间:2020-07-07 03:25:23

标签: amazon-web-services amazon-s3 aws-codepipeline aws-codebuild

buildspec.yml

version: 0.1
environment_variables:
    plaintext:
        S3_BUCKET: "test"
phases:
    install:
        commands:
            - echo Installing source NPM dependencies...
            - npm install
            - npm install -g @angular/cli
    build:
        commands:
            - echo Build started on `date`
            - ng build --prod -c=staging --output-hashing all
    post_build:
         commands:
            - aws s3 rm s3://${S3_BUCKET} --recursive
            - aws s3 cp dist s3://${S3_BUCKET} --recursive
            - echo Build completed on `date`
artifacts:
    files:
        - '**/*'
    base-directory: 'dist*'
    discard-paths: yes

错误: cloudwatch日志

pyenv:未安装版本“ 2.7.15”(由/codebuild/output/src298161583/src/.python-version设置)

2020-07-06T19:33:12.830-04:00

2020-07-06T19:33:12.830-04:00 [容器] 2020/07/06 23:33:12命令未成功退出aws s3 rm s3:// $ {S3_BUCKET}-递归退出状态1

1 个答案:

答案 0 :(得分:0)

能否请您尝试升级到buildspec version 0.2?例如

version: 0.2
env:
    variables:
        S3_BUCKET: "test"
phases:
    install:
        runtime-versions:
            python: 3.8
        commands:
            - echo Installing source NPM dependencies...
            - npm install
            - npm install -g @angular/cli
    build:
        commands:
            - echo Build started on `date`
            - ng build --prod -c=staging --output-hashing all
    post_build:
         commands:
            - aws s3 rm s3://${S3_BUCKET} --recursive
            - aws s3 cp dist s3://${S3_BUCKET} --recursive
            - echo Build completed on `date`
artifacts:
    files:
        - '**/*'
    base-directory: 'dist*'
    discard-paths: yes

基于输出

pyenv:未安装版本“ 2.7.15”(由/codebuild/output/src298161583/src/.python-version设置)

似乎正在请求Python运行时。在其中的一条评论中,您提到使用了CodeBuild Docker映像Ubuntu 18.04 aws/code-build/standard:4.0。遗憾的是,此映像仅支持Python version 3.7 and 3.8(而不是版本2.x),因此在上面更新的buildspec中的runtime-versions中添加了python: 3.8。因此,您仍然有可能必须解决错误。