-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pipelines):
additionalInputs
fails for deep directory (#17074)
If the directory is nested deeper than one level underneath `.` or `..`, the wrong directory gets created. Also add in protection against the directory already existing, in which case the same behavior would happen. Fixes #16936. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
3 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/@aws-cdk/pipelines/test/codepipeline/codebuild-step.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Template, Match } from '@aws-cdk/assertions'; | ||
import { Stack } from '@aws-cdk/core'; | ||
import * as cdkp from '../../lib'; | ||
import { PIPELINE_ENV, TestApp } from '../testhelpers'; | ||
|
||
let app: TestApp; | ||
let pipelineStack: Stack; | ||
|
||
beforeEach(() => { | ||
app = new TestApp(); | ||
pipelineStack = new Stack(app, 'PipelineStack', { env: PIPELINE_ENV }); | ||
}); | ||
|
||
afterEach(() => { | ||
app.cleanup(); | ||
}); | ||
|
||
test('additionalinputs creates the right commands', () => { | ||
// WHEN | ||
new cdkp.CodePipeline(pipelineStack, 'Pipeline', { | ||
synth: new cdkp.CodeBuildStep('Synth', { | ||
commands: ['/bin/true'], | ||
input: cdkp.CodePipelineSource.gitHub('test/test', 'main'), | ||
additionalInputs: { | ||
'some/deep/directory': cdkp.CodePipelineSource.gitHub('test2/test2', 'main'), | ||
}, | ||
}), | ||
}); | ||
|
||
// THEN | ||
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', { | ||
Source: { | ||
BuildSpec: Match.serializedJson(Match.objectLike({ | ||
phases: { | ||
install: { | ||
commands: [ | ||
'[[ ! -d "some/deep/directory" ]] || { echo \'additionalInputs: "some/deep/directory" must not exist yet. If you want to merge multiple artifacts, use a "cp" command.\'; exit 1; } && mkdir -p -- "some/deep" && ln -s -- "$CODEBUILD_SRC_DIR_test2_test2_Source" "some/deep/directory"', | ||
], | ||
}, | ||
}, | ||
})), | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters