Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cdk-pipelines] CodeBuild fails when deploying pipeline stack from Windows #11359

Closed
awohletz opened this issue Nov 8, 2020 · 2 comments · Fixed by #11464
Closed

[cdk-pipelines] CodeBuild fails when deploying pipeline stack from Windows #11359

awohletz opened this issue Nov 8, 2020 · 2 comments · Fixed by #11464
Assignees
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@awohletz
Copy link

awohletz commented Nov 8, 2020

I followed this CdkPipelines tutorial exactly, except that I used the subdirectory option of the synth action, because I have my CDK code in a monorepo:

synthAction: SimpleSynthAction.standardNpmSynth({
    subdirectory: "packages/infrastructure",
    cloudAssemblyArtifact,
    sourceArtifact,
    buildCommand: "npm run build"
}),

When I followed the tutorial's command to deploy my pipeline stack, the CodeBuild step failed after deploy. I figured out that when run on Windows, the pipeline deployment command creates backward slashes for the base-directory in the generated buildSpec. When I run the pipeline deploy on Linux, it creates forward slashes, and then the CodeBuild succeeds. Thus, it appears that CdkPipelines does not properly handle cross-platform path separators.

Reproduction Steps

Follow the CdkPipelines tutorial, use the subdirectory option, and run npx cdk deploy \ --profile account1-profile \ CdkpipelinesDemoPipelineStack from Windows PowerShell.

What did you expect to happen?

I expected the pipeline to create and all steps succeed, as in the screenshot in the tutorial.

What actually happened?

The CodeBuild step failed.

Environment

  • CDK CLI Version : 1.72.0
  • Framework Version: 1.72.0
  • Node.js Version: 12.5.0
  • OS : Windows 10
  • Language (Version): TypeScript ~3.9.7

Other

On Windows, the outputted PipelineStack.template.json has:

"Source": {
          "BuildSpec": "{\n  \"version\": \"0.2\",\n  \"phases\": {\n    \"pre_build\": {\n      \"commands\": [\n        \"cd packages/infrastructure\",\n        \"npm ci\"\n      ]\n    },\n    \"build\": {\n      \"commands\": [\n        \"npm run build\",\n        \"npx cdk synth\"\n      ]\n    }\n  },\n  \"artifacts\": {\n    \"base-directory\": \"packages\\\\infrastructure\\\\cdk.out\",\n    \"files\": \"**/*\"\n  }\n}",
          "Type": "CODEPIPELINE"
        },

On Linux:

"Source": {
          "BuildSpec": "{\n  \"version\": \"0.2\",\n  \"phases\": {\n    \"pre_build\": {\n      \"commands\": [\n        \"cd packages/infrastructure\",\n        \"npm ci\"\n      ]\n    },\n    \"build\": {\n      \"commands\": [\n        \"npm run build\",\n        \"npx cdk synth\"\n      ]\n    }\n  },\n  \"artifacts\": {\n    \"base-directory\": \"packages/infrastructure/cdk.out\",\n    \"files\": \"**/*\"\n  }\n}",
          "Type": "CODEPIPELINE"
        },

When deployed via Windows, the CodeBuild logs show:


[Container] 2020/11/08 17:30:21 Entering phase POST_BUILD
--
835 | [Container] 2020/11/08 17:30:21 Phase complete: POST_BUILD State: SUCCEEDED
836 | [Container] 2020/11/08 17:30:21 Phase context status code:  Message:
837 | [Container] 2020/11/08 17:30:21 Expanding base directory path: packages\infrastructure\cdk.out
838 | [Container] 2020/11/08 17:30:21 Assembling file list
839 | [Container] 2020/11/08 17:30:21 Expanding packages\infrastructure
840 | [Container] 2020/11/08 17:30:21 Skipping invalid file path packages\infrastructure

When deployed via Linux, the CodeBuild logs show:

[Container] 2020/11/08 17:59:33 Entering phase POST_BUILD
--
572 | [Container] 2020/11/08 17:59:33 Phase complete: POST_BUILD State: SUCCEEDED
573 | [Container] 2020/11/08 17:59:33 Phase context status code:  Message:
574 | [Container] 2020/11/08 17:59:33 Expanding base directory path: packages/infrastructure/cdk.out
575 | [Container] 2020/11/08 17:59:33 Assembling file list
576 | [Container] 2020/11/08 17:59:33 Expanding packages/infrastructure/cdk.out
577 | [Container] 2020/11/08 17:59:33 Expanding file paths for base directory packages/infrastructure/cdk.out
578 | [Container] 2020/11/08 17:59:33 Assembling file list
579 | [Container] 2020/11/08 17:59:33 Expanding **/*
580 | [Container] 2020/11/08 17:59:33 Found 5 file(s)

This is 🐛 Bug Report

@awohletz awohletz added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 8, 2020
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Nov 8, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 9, 2020

Whoopsiedoodle! You are right!

@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort p1 labels Nov 9, 2020
@rix0rrr rix0rrr added this to the [GA] CDK Pipelines milestone Nov 9, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Nov 9, 2020
@mergify mergify bot closed this as completed in #11464 Nov 15, 2020
mergify bot pushed a commit that referenced this issue Nov 15, 2020
Pipelines generates path references based on the local system's
file tree, and uses `path.join()` (etc) to build those.

On a Windows machine, those would use a `\\` as a path separator,
but the path separator for CodePipeline and the Linux CodeBuild image
we use should be a `/`.

Translate them.

Fixes #11359, fixes #11405, fixes #11424.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants