【发布时间】:2018-03-11 10:42:33
【问题描述】:
我尝试使用代码管道来自动化代码部署。它使用 wiki 中提到的 Git Hub -> Code Build -> Cloud Formation
在this thread 建议的一些更改之后,我设法让管道运行
但是,每当我使用代码管道时,Lambda 测试都会失败,提示找不到该类。
为了验证,我直接在AWS lambda控制台上传了jar,效果很好。
我还验证了由 S3“MyAppBuild”文件夹中的 aws 代码构建构建的 jar,它包含 zip 文件中 target/app-1.0-SNAPSHOT.jar 中的 jar 文件以及我的 SamTemplate.yml。
这是 SamTemplate.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Outputs the time
Parameters:
SourceBucket:
Type: String
Description: S3 bucket name for the CodeBuild artifact
SourceArtifact:
Type: String
Description: S3 object key for the CodeBuild artifact
Resources:
TimeFunction:
Type: AWS::Serverless::Function
Properties:
Handler: com.xxx.Hello::handleRequest
Runtime: java8
CodeUri:
Bucket: !Ref SourceBucket
Key: !Ref SourceArtifact
Events:
MyTimeApi:
Type: Api
Properties:
Path: /TimeResource
Method: GET
这里是 buildSpec.yaml
version: 0.2
phases:
build:
commands:
- echo Build started on `date`
- mvn test
post_build:
commands:
- echo Build completed on `date`
- mvn package
install:
commands:
- aws cloudformation package --template-file SamTemplate.yaml --s3-bucket codepipeline-us-east-1-xxxx
--output-template-file NewSamTemplate.yaml
artifacts:
type: zip
files:
- SamTemplate.yaml
- target/app-1.0-SNAPSHOT.jar
有什么建议可以试试吗? 我使用 Maven。
【问题讨论】:
标签: aws-lambda amazon-cloudformation aws-codebuild aws-sam-cli