Amazon web services AWS CodePipeline BuildAction未检测buildspec.yml次要构件
我正在尝试使用辅助构件将网页中的文件与cdk生成的堆栈文件分离。但是来自管道的BuildAction并没有检测到将web文件与堆栈文件分离的次要工件 我尝试过遵循AWS文档中与buildspec.yml以及多个源和多个输出相关的建议,但无法使其正常工作 这是我的构建操作的cdk代码Amazon web services AWS CodePipeline BuildAction未检测buildspec.yml次要构件,amazon-web-services,pipeline,aws-cdk,aws-codepipeline,Amazon Web Services,Pipeline,Aws Cdk,Aws Codepipeline,我正在尝试使用辅助构件将网页中的文件与cdk生成的堆栈文件分离。但是来自管道的BuildAction并没有检测到将web文件与堆栈文件分离的次要工件 我尝试过遵循AWS文档中与buildspec.yml以及多个源和多个输出相关的建议,但无法使其正常工作 这是我的构建操作的cdk代码 const buildStage = pipeline.addStage({ stageName: 'Build'}); const buildOutputWeb = new Artifact(&qu
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"
},
这是我的建筑规范
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
webapp
和模板
此块中的每个工件标识符必须与项目的secondaryArtifacts属性中定义的工件匹配
在您在问题中发布的内容中,我没有看到任何证据表明您的构建项目中定义了辅助输出。这可能解释了为什么会出现“无定义”的错误。我解决了这个问题。
结果表明,次要工件中的name属性不会更改标识符。
我的buildspec.yml工件现在看起来像这样
artifacts:
secondary-artifacts:
webapp:
base-directory: packages/website/dist
files:
- '**/*'
name: webapp
template:
base-directory: packages/infrastructure/cdk.out
files:
- 'WavelengthAppStack.template.json'
name: template
请注意,现在不是artifact1:
然后是该工件的所有数据,而是webapp:
然后是所有数据。有代码构建错误吗?客户端错误:BuildSpect中没有对二级工件webapp的定义问题是,它是用于未在管道中使用的代码构建项目。PipelineProject没有引用次要工件的属性。我尝试添加次要工件,但出现此错误。具有CodePipeline源的项目不能具有辅助构件。改用CodeBuild管道操作“输出”
属性