簡體   English   中英

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

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

在按照github 上解決方案和 Stack Overflow 上的解決方案進行操作后,我在使用 AWS CDK 構建代碼管道時仍然遇到同樣的問題。

錯誤:

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)

此錯誤出現在代碼管道的代碼構建階段。 作為第一階段,從 Code Commit 獲取代碼成功。

CDK 流水線代碼:

正如您在下面的代碼中看到的,我有卸載 cdk 的安裝命令,然后重新安裝它。 這是上面文檔提供的推薦解決方案。 重新排序不影響結果。

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",
  })
});

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"
  }

解決方案是在npx cdk synth中不使用npx 我刪除了它並且代碼有效。 嘗試在本地運行npx cdk synth時也遇到過這種情況。

解決方案: cdk synth

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM