Skip to content

Commit

Permalink
feat(pipelines) ShellScriptAction add option to configure codebuild e…
Browse files Browse the repository at this point in the history
…nvironment

The build environment for the ShellScriptAction is hardcoded and set to LINUX_4_0.

This fix allows the build environment to be specified in the ShellScriptAction
fixes aws#10919
  • Loading branch information
tdikland committed Oct 30, 2020
1 parent e7ddf3d commit bf24aad
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface ShellScriptActionProps {
readonly additionalArtifacts?: codepipeline.Artifact[];

/**
* The CodeBuild image used for the build.
* The CodeBuild environment where scripts are executed.
*
* @default LinuxBuildImage.STANDARD_4_0
*/
Expand Down
35 changes: 33 additions & 2 deletions packages/@aws-cdk/pipelines/test/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ test('run ShellScriptAction with specified codebuild image', () => {
actionName: 'imageAction',
additionalArtifacts: [integTestArtifact],
commands: ['true'],
buildImage: codebuild.LinuxBuildImage.STANDARD_2_0,
environment: { buildImage: codebuild.LinuxBuildImage.STANDARD_2_0 },
}));

// THEN
Expand All @@ -353,7 +353,38 @@ test('run ShellScriptAction with specified codebuild image', () => {
});
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: 'aws/codebuild/standard:2.0',
},
});
});

test('run ShellScriptAction with specified BuildEnvironment', () => {
// WHEN
pipeline.addStage('Test').addActions(new cdkp.ShellScriptAction({
actionName: 'imageAction',
additionalArtifacts: [integTestArtifact],
commands: ['true'],
environment: {
buildImage: codebuild.LinuxBuildImage.STANDARD_2_0,
computeType: codebuild.ComputeType.LARGE,
environmentVariables: { FOO: { value: 'BAR', type: codebuild.BuildEnvironmentVariableType.PLAINTEXT } },
privileged: true,
},
}));

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:2.0',
PrivilegedMode: true,
ComputeType: 'BUILD_GENERAL1_LARGE',
EnvironmentVariables: [
{
Type: 'PLAINTEXT',
Value: 'BAR',
Name: 'FOO',
},
],
},
});
});
Expand Down

0 comments on commit bf24aad

Please sign in to comment.