您好,如果我在使用 AWS 云开发工具包 (CDK) 部署代码管道时收到此错误的可能来源,我将不胜感激
我有一个 Typecript CDK 项目(cdk init --language typescript)。这使用 GitHub 挂钩在我的 GitHub 存储库中的分支的每次更新上进行部署。这一步工作正常。但是,构建后步骤发生失败并出现错误
“阶段上下文状态代码:CLIENT_ERROR 消息:找不到与 cdk.out 匹配的基本目录路径”
从下面的代码中,您可以看到我使用了 @aws-cdk/pipelines 、 SimpleSynthAction.standardNpmSynth,我认为这不会生成 cdk.out 文件 (?)。任何有助于我解决此问题的评论将不胜感激
import { Construct, SecretValue, Stack, StackProps } from '@aws-cdk/core';
import * as cp from '@aws-cdk/aws-codepipeline';
import * as cpa from '@aws-cdk/aws-codepipeline-actions';
import * as pipelines from '@aws-cdk/pipelines';
import { WebServiceStage } from './webservice_stage';
export class MyPipelineStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const sourceArtifact = new cp.Artifact();
const cloudAssemblyArtifact = new cp.Artifact();
const sourceAction = new cpa.GitHubSourceAction({
actionName: 'GitHub',
output: sourceArtifact,
oauthToken: SecretValue.secretsManager('github-token'),
owner: 'owner',
repo: 'repo-name',
branch:'branch-name'
});
const synthAction = pipelines.SimpleSynthAction.standardNpmSynth({
sourceArtifact,
cloudAssemblyArtifact,
buildCommand: 'npm install && npm run build && npm test',
synthCommand: 'npm run synth'
});
const pipeline = new pipelines.CdkPipeline(this, 'Pipeline', {
cloudAssemblyArtifact,
sourceAction,
synthAction
});
// Dev stage
const development = new WebServiceStage(this, 'Development');
pipeline.addApplicationStage(development);
}
}
npm 'npm run syth' 只是调用 'cdk synth'
我尝试在我的 /bin/my_pipeline.ts 文件中运行 app.synth() ,但这并不能解决错误。
再一次,我已经用谷歌搜索了这个地狱并且无法解决它,所以非常感谢任何帮助。如果它在这里有任何用途是我在构建日志中输出的 buildSpec 部分
BuildSpec: >-
{
"version": "0.2",
"phases": {
"pre_build": {
"commands": [
"npm ci"
]
},
"build": {
"commands": [
"cd partnerportal_cicd_pipeline && npm install && npm run build && npm test",
"npm run synth"
]
}
},
"artifacts": {
"base-directory": "cdk.out",
"files": "**/*"
}
}