我正在学习 codepipeline,以使用 CodeBuild 将构建推送到 ECR。下面是我的 buildspec.yml 文件和 Codebuild 日志中的错误。谁能阐明我做错了什么?提前致谢。
构建规范.yml
版本:0.2
阶段:
预构建:
commands:
- echo Logging in to Amazon ECR.....
- aws --version
- $(aws ecr get-login --no-include-email --region us-east-1)
- REPOSITORY_URI=989066xxxxxx.dkr.ecr.us-east-1.amazonaws.com/ecs-cicd-nginx
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
Run Code Online (Sandbox Code Playgroud)
建造:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:$IMAGE_TAG .
Run Code Online (Sandbox Code Playgroud)
构建后:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-codepipeline amazon-ecr aws-codebuild buildspec
这是 codebuild 使用的 buildspec.yml 文件:
version: 0.2
env:
shell: bash
phases:
install:
runtime-versions:
nodejs: 14
pre_build:
commands:
- echo Installing source NPM dependencies...
- npm install -g aws-cdk
- npm install -g typescript
- npm install
- npm run build
build:
commands:
- cdk --version
- cdk ls
- cdk synth
post_build:
Run Code Online (Sandbox Code Playgroud)
/usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk npm 警告 notsup 不支持 aws-cdk@2.9.0 引擎:想要:{"node":">= 14.15.0"}(当前:{"node":"12.22.2","npm":"6.14.13"})npm WARN notsup 与您的node/npm 版本不兼容:aws-cdk@2.9.0
最后cdk ls失败
感谢任何帮助,因为我已经尝试删除 node-modules 和 package-lock.json。
我正在使用 AWS CodePipeline,它从我的 git 存储库获取源代码,使用CodeBuildbuildSpec 构建输出工件并将其保存到 S3 存储桶,最终部署到Elastic BeanStalk(NodeJS 环境)。
一切正常,但我需要管道从我的AWS S3存储桶之一复制 1 个特定文件并将其添加到,output artifacts然后再将其部署到EB
可以使用 buildSpec 来完成吗?
artifacts:
files:
- '**/*'
# - How to add a file from S3 to the artifacts?
Run Code Online (Sandbox Code Playgroud) amazon-s3 amazon-web-services aws-codepipeline aws-codebuild buildspec