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

fix(pipelines): pipeline doesn't restart if CLI version changes #10727

Merged
merged 2 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export class PublishAssetsAction extends CoreConstruct implements codepipeline.I
project,
input: this.props.cloudAssemblyInput,
role: props.role,
// Add this purely so that the pipeline will selfupdate if the CLI version changes
environmentVariables: props.cdkCliVersion ? {
CDK_CLI_VERSION: { value: props.cdkCliVersion },
} : undefined,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export class UpdatePipelineAction extends CoreConstruct implements codepipeline.
actionName: 'SelfMutate',
input: props.cloudAssemblyInput,
project: selfMutationProject,
// Add this purely so that the pipeline will selfupdate if the CLI version changes
environmentVariables: props.cdkCliVersion ? {
CDK_CLI_VERSION: { value: props.cdkCliVersion },
} : undefined,
});
}

Expand Down
27 changes: 27 additions & 0 deletions packages/@aws-cdk/pipelines/test/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,33 @@ test('can control fix/CLI version used in pipeline selfupdate', () => {
});
});

test('changing CLI version leads to a different pipeline structure (restarting it)', () => {
// GIVEN
const stack2 = new Stack(app, 'Stack2', { env: PIPELINE_ENV });
const stack3 = new Stack(app, 'Stack3', { env: PIPELINE_ENV });
const structure2 = Capture.anyType();
const structure3 = Capture.anyType();

// WHEN
new TestGitHubNpmPipeline(stack2, 'Cdk', {
cdkCliVersion: '1.2.3',
});
new TestGitHubNpmPipeline(stack3, 'Cdk', {
cdkCliVersion: '4.5.6',
});

// THEN
expect(stack2).toHaveResourceLike('AWS::CodePipeline::Pipeline', {
Stages: structure2.capture(),
});
expect(stack3).toHaveResourceLike('AWS::CodePipeline::Pipeline', {
Stages: structure3.capture(),
});

expect(JSON.stringify(structure2.capturedValue)).not.toEqual(JSON.stringify(structure3.capturedValue));

});

test('add another action to an existing stage', () => {
// WHEN
pipeline.stage('Source').addAction(new cpa.GitHubSourceAction({
Expand Down