你好,我非常感谢在使用(CDK)部署代码管道时对此错误的可能来源的任何评论。
我有一个Typecript CDK项目(cdk init -语言类型记录)。这使用一个GitHub钩子在我的GitHub存储库中的每个分支更新上部署。这一步很好用。但是,如果出现错误,则post生成步骤将失败。
“阶段上下文状态代码: CLIENT_ERROR消息:没有为cdk.out找到匹配的基本目录路径”
从下面的代码中可以看到,我使用@aws/管道,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运行系统‘刚刚调用'cdk synth’
我尝试在我的/bin/ my _管线. the文件中运行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": "**/*"
}
}发布于 2021-12-10 18:00:01
在使用CDK v2时,我也遇到了同样的错误。
在我的例子中,我必须指定CodePipeline可以通过primaryOutputDirectory选项期望cdk.out文件的子目录。
默认情况下,CodePipeline期望这个dir位于项目的根中,这就是它失败的原因。
带有子目录的示例配置
const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
synth: new pipelines.ShellStep('Synth', {
input: source,
commands: [
'cd mysubdir',
'npm ci',
'npm run build',
'npx cdk synth',
],
primaryOutputDirectory: 'mysubdir/cdk.out',
}),
});相关文档。
发布于 2021-10-16 13:11:47
对我来说,问题在于cdk.out必须位于存储库的根文件夹中,因此我添加了一个新命令: mv cdk.out ./。
发布于 2021-01-20 16:57:45
我让它正常工作,我不得不破坏已部署的堆栈,然后运行'cdk引导--cloudformation-execution-policies'arn:aws:iam::aws:policy/AdministratorAccess',‘,然后确保所有东西都被推送到回购程序中,最后再次运行'cdk部署’。我想,因为我没有这么做,我的'synthCommand‘没有生效。
https://stackoverflow.com/questions/65811487
复制相似问题