【发布时间】:2020-10-04 20:30:02
【问题描述】:
我正在尝试使用辅助工件将网页中的文件与 cdk 生成的堆栈文件分开。但是管道中的 BuildAction 没有检测到将 Web 文件与 Stack 文件分开的辅助工件。
我已尝试遵循 AWS 文档中有关 buildspec.yml 以及多个来源和多个输出的建议,但无法使其正常工作。
这是我用于构建操作的 cdk 代码。
const buildStage = pipeline.addStage({ stageName: 'Build'});
const buildOutputWeb = new Artifact("webapp")
const buildOutputTemplates = new Artifact("template")
const project = new PipelineProject(this, 'Wavelength_build', {
environment: {
buildImage: LinuxBuildImage.STANDARD_3_0
},
projectName: 'WebBuild'
});
buildStage.addAction(new CodeBuildAction({
actionName: 'Build',
project,
input: sourceOutput,
outputs: [buildOutputWeb, buildOutputTemplates]
}));
这是与生成的堆栈文件中的构建操作相关的部分
{
"Actions": [
{
"ActionTypeId": {
"Category": "Build",
"Owner": "AWS",
"Provider": "CodeBuild",
"Version": "1"
},
"Configuration": {
"ProjectName": {
"Ref": "Wavelengthbuild7D63C781"
}
},
"InputArtifacts": [
{
"Name": "SourceOutput"
}
],
"Name": "Build",
"OutputArtifacts": [
{
"Name": "webapp"
},
{
"Name": "template"
}
],
"RoleArn": {
"Fn::GetAtt": [
"WavelengthPipelineBuildCodePipelineActionRoleC08CF8E2",
"Arn"
]
},
"RunOrder": 1
}
],
"Name": "Build"
},
这是我的 buildspec.yml
version: 0.2
env:
variables:
S3_BUCKET: "wavelenght-web.ronin-ddd-dev-web.net"
phases:
install:
runtime-versions:
nodejs: 10
pre_build:
commands:
- echo Installing source NPM dependencies...
- npm install -g @angular/cli
- npm install typescript -g
- npm install -D lerna
build:
commands:
- echo Build started on `date`
- npm run release
- cd $CODEBUILD_SRC_DIR
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- '**/*'
secondary-artifacts:
artifact1:
base-directory: $CODEBUILD_SRC_DIR
files:
- 'packages/website/dist/**/*'
name: webapp
discard-paths: yes
artifact2:
base-directory: $CODEBUILD_SRC_DIR
files:
- '*/WavelengthAppStack.template.json'
name: template
discard-paths: yes
【问题讨论】:
-
任何 CodeBuild 错误?
-
CLIENT_ERROR: buildspec 中没有二级工件 webapp 的定义
标签: amazon-web-services pipeline aws-cdk aws-codepipeline