简体   繁体   English

Cloud Assembly Schema 版本不匹配——在 CDK 中构建代码管道

[英]Cloud Assembly Schema Version Mismatch - Building A Code Pipeline In The CDK

After following the solution on github , and the solution on Stack Overflow , I am still experiencing the same issue when building a code pipeline with AWS CDK.在按照github 上解决方案和 Stack Overflow 上的解决方案进行操作后,我在使用 AWS CDK 构建代码管道时仍然遇到同样的问题。

Error:错误:

This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version.
(Cloud assembly schema version mismatch: Maximum schema version supported is 21.0.0, but found 22.0.0)

This error appears in the Code Build Stage of the Code Pipeline.此错误出现在代码管道的代码构建阶段。 Sourcing the code from Code Commit works successfully, as the first stage.作为第一阶段,从 Code Commit 获取代码成功。

CDK Pipeline Code: CDK 流水线代码:

As you can see in the code below, I have the install commands of uninstalling the cdk, and then installing it again.正如您在下面的代码中看到的,我有卸载 cdk 的安装命令,然后重新安装它。 This was the recommended solution provided by the document above.这是上面文档提供的推荐解决方案。 Re-ordering does not influence the outcome.重新排序不影响结果。

this.codePipeline = new CodePipeline(this, `${environment}-${appName}-`, {
  pipelineName: `${environment}-${appName}-`,
  selfMutation: true,
  crossAccountKeys: false,
  role: this.codePipelineRole,
  synth: new ShellStep("Deployment", {
    input: CodePipelineSource.codeCommit(this.codeRepository, environment, {
      codeBuildCloneOutput: true
    }),
    installCommands: ["npm uninstall -g aws-cdk", "npm i -g npm@latest", "npm install -g aws-cdk"],
    commands: [
      "cd backend",
      "npm ci",
      "npm run build",
      "npx cdk synth",
    ],
    primaryOutputDirectory: "backend/cdk.out",
  })
});

Dependencies in the package.json file: package.json文件中的依赖:

  "dependencies": {
    "@aws-cdk/aws-appsync-alpha": "^2.55.1-alpha.0",
    "aws-cdk-lib": "^2.58.0",
    "aws-sdk": "^2.1278.0",
    "constructs": "^10.1.204",
    "git-branch": "^2.0.1",
    "source-map-support": "^0.5.21"
  }

The solution was to do without the npx in npx cdk synth .解决方案是在npx cdk synth中不使用npx I removed it and the code worked.我删除了它并且代码有效。 This was also experienced when attempting to run npx cdk synth locally.尝试在本地运行npx cdk synth时也遇到过这种情况。

Solution: cdk synth解决方案: cdk synth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS CDK - 导入错误:无法从“aws_cdk.cloud_assembly_schema”导入名称“AssetManifestOptions” - AWS CDK - ImportError: cannot import name 'AssetManifestOptions' from 'aws_cdk.cloud_assembly_schema' 通过 AWS 上的 CDK 管道构建代码时,我可以在 Github 上标记我的代码吗? - Can I tag my code on Github when building it through a CDK Pipeline on AWS? 如何解决 CDK CLI 版本不匹配的问题 - How to solve CDK CLI version mismatch 如何指定目录来触发代码管道cdk? - How to Specify directory to trigger code pipeline cdk? 使用 CodeBuildStep 的代码管道的 AWS CDK 合成器错误 - AWS CDK synth errors out for a Code Pipeline with CodeBuildStep AWS CDK 代码管道开发 - Typescript 错误 TS2307 - AWS CDK Code Pipeline Development - Typescript Error TS2307 AWS CDK 代码管道开发 - 错误 TS1005:预期为“]” - AWS CDK Code Pipeline Development - error TS1005: ']' expected 如何创建代码管道阶段以在 github 中部署带有源代码的 React 应用程序? [CDK 2.0] - How to create a code pipeline stage to deploy React application with source code in github? [CDK 2.0] 在 CDK ShellStep(管道)步骤中使用 AWS CLI - Use the AWS CLI in a CDK ShellStep (pipeline) step AWS CDK 代码管道开发——NodejsFunction Package.json 依赖项如何安装? - AWS CDK Code Pipeline Development - How Do I Install NodejsFunction Package.json Dependencies?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM