Skip to content

Commit f6dab8d

Browse files
authored
fix(pipelines): CodeBuild projects are hard to tell apart (#18492)
CDK Pipelines generates a number of CodeBuild projects, and they are hard to tell apart some times. Add `Description` fields to each of them. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 525ac07 commit f6dab8d

File tree

5 files changed

+96
-1
lines changed

5 files changed

+96
-1
lines changed

packages/@aws-cdk/pipelines/lib/codepipeline/_codebuild-factory.ts

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export class CodeBuildFactory implements ICodePipelineActionFactory {
273273

274274
const project = new codebuild.PipelineProject(projectScope, this.constructId, {
275275
projectName: this.props.projectName,
276+
description: `Pipeline step ${options.pipeline.pipeline.pipelineName}/${stage.stageName}/${actionName}`,
276277
environment,
277278
vpc: projectOptions.vpc,
278279
subnetSelection: projectOptions.subnetSelection,

packages/@aws-cdk/pipelines/test/codepipeline/codebuild-step.test.ts

+22
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ test('additionalinputs creates the right commands', () => {
4343
});
4444
});
4545

46+
test('CodeBuild projects have a description', () => {
47+
new cdkp.CodePipeline(pipelineStack, 'Pipeline', {
48+
synth: new cdkp.CodeBuildStep('Synth', {
49+
commands: ['/bin/true'],
50+
input: cdkp.CodePipelineSource.gitHub('test/test', 'main'),
51+
}),
52+
});
53+
54+
// THEN
55+
Template.fromStack(pipelineStack).hasResourceProperties(
56+
'AWS::CodeBuild::Project',
57+
{
58+
Description: {
59+
'Fn::Join': [
60+
'',
61+
['Pipeline step ', { Ref: 'Pipeline9850B417' }, '/Build/Synth'],
62+
],
63+
},
64+
},
65+
);
66+
});
67+
4668
test('long duration steps are supported', () => {
4769
// WHEN
4870
new cdkp.CodePipeline(pipelineStack, 'Pipeline', {

packages/@aws-cdk/pipelines/test/integ.newpipeline-with-vpc.expected.json

+48
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,18 @@
13551355
"Cache": {
13561356
"Type": "NO_CACHE"
13571357
},
1358+
"Description": {
1359+
"Fn::Join": [
1360+
"",
1361+
[
1362+
"Pipeline step ",
1363+
{
1364+
"Ref": "Pipeline9850B417"
1365+
},
1366+
"/Build/Synth"
1367+
]
1368+
]
1369+
},
13581370
"EncryptionKey": "alias/aws/s3",
13591371
"VpcConfig": {
13601372
"SecurityGroupIds": [
@@ -1942,6 +1954,18 @@
19421954
"Cache": {
19431955
"Type": "NO_CACHE"
19441956
},
1957+
"Description": {
1958+
"Fn::Join": [
1959+
"",
1960+
[
1961+
"Pipeline step ",
1962+
{
1963+
"Ref": "Pipeline9850B417"
1964+
},
1965+
"/UpdatePipeline/SelfMutate"
1966+
]
1967+
]
1968+
},
19451969
"EncryptionKey": "alias/aws/s3",
19461970
"VpcConfig": {
19471971
"SecurityGroupIds": [
@@ -2284,6 +2308,18 @@
22842308
"Cache": {
22852309
"Type": "NO_CACHE"
22862310
},
2311+
"Description": {
2312+
"Fn::Join": [
2313+
"",
2314+
[
2315+
"Pipeline step ",
2316+
{
2317+
"Ref": "Pipeline9850B417"
2318+
},
2319+
"/Assets/FileAsset1"
2320+
]
2321+
]
2322+
},
22872323
"EncryptionKey": "alias/aws/s3",
22882324
"VpcConfig": {
22892325
"SecurityGroupIds": [
@@ -2385,6 +2421,18 @@
23852421
"Cache": {
23862422
"Type": "NO_CACHE"
23872423
},
2424+
"Description": {
2425+
"Fn::Join": [
2426+
"",
2427+
[
2428+
"Pipeline step ",
2429+
{
2430+
"Ref": "Pipeline9850B417"
2431+
},
2432+
"/Assets/FileAsset2"
2433+
]
2434+
]
2435+
},
23882436
"EncryptionKey": "alias/aws/s3",
23892437
"VpcConfig": {
23902438
"SecurityGroupIds": [

packages/@aws-cdk/pipelines/test/integ.newpipeline.expected.json

+24
Original file line numberDiff line numberDiff line change
@@ -2036,6 +2036,18 @@
20362036
"Cache": {
20372037
"Type": "NO_CACHE"
20382038
},
2039+
"Description": {
2040+
"Fn::Join": [
2041+
"",
2042+
[
2043+
"Pipeline step ",
2044+
{
2045+
"Ref": "Pipeline9850B417"
2046+
},
2047+
"/Build/Synth"
2048+
]
2049+
]
2050+
},
20392051
"EncryptionKey": "alias/aws/s3"
20402052
}
20412053
},
@@ -2335,6 +2347,18 @@
23352347
"Cache": {
23362348
"Type": "NO_CACHE"
23372349
},
2350+
"Description": {
2351+
"Fn::Join": [
2352+
"",
2353+
[
2354+
"Pipeline step ",
2355+
{
2356+
"Ref": "Pipeline9850B417"
2357+
},
2358+
"/UpdatePipeline/SelfMutate"
2359+
]
2360+
]
2361+
},
23382362
"EncryptionKey": "alias/aws/s3"
23392363
}
23402364
}

packages/@aws-cdk/pipelines/test/testhelpers/matchers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class StringLike extends Matcher {
2626

2727
public test(actual: any): MatchResult {
2828
if (typeof(actual) !== 'string') {
29-
throw new Error(`Expected string but found ${typeof(actual)}`);
29+
throw new Error(`Expected string but found ${typeof(actual)} ${JSON.stringify(actual)}`);
3030
}
3131
const re = new RegExp(`^${this.pattern.split('*').map(escapeRegex).join('.*')}$`);
3232

0 commit comments

Comments
 (0)