Skip to content

Commit

Permalink
fix: CodeBuild status reporting uses project name as a key in Bitbuck…
Browse files Browse the repository at this point in the history
…et reporting
  • Loading branch information
markusl committed Dec 7, 2021
1 parent 74df45b commit 59803f7
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .projenrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const {
AwsCdkConstructLibrary,
awscdk,
} = require('projen');

const AWS_CDK_LATEST_RELEASE = '2.0.0';

const PROJECT_NAME = 'cdk-codepipeline-bitbucket-build-result-reporter';
const PROJECT_DESCRIPTION = 'A JSII construct lib for reporting AWS CodePipeline and build statuses to a Bitbucket server instance';

const project = new AwsCdkConstructLibrary({
const project = new awscdk.AwsCdkConstructLibrary({
name: PROJECT_NAME,
description: PROJECT_DESCRIPTION,
authorName: 'Markus Lindqvist',
Expand Down
2 changes: 1 addition & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/index.CodeBuildStatusHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const buildBitbucketBuildStatusBody = async (
const buildId = detail['build-id'].split(':').slice(-1)[0];
return {
state,
key: `${detail['project-name']}-${buildId}`,
name: `CodeBuild-${detail['project-name']} (${await getCurrentAccountAlias(event.account)})`,
key: detail['project-name'],
name: `CodeBuild ${detail['project-name']} (${await getCurrentAccountAlias(event.account)} @ ${event.region})`,
url: `https://${event.region}.console.aws.amazon.com/codesuite/codebuild/${event.account}/projects/${detail['project-name']}/build/${detail['project-name']}:${buildId}/?region=${event.region}`,
description: `${detail['project-name']} build initiated by ${detail['additional-information'].initiator} at ${detail['additional-information']['build-start-time']}`,
};
Expand Down
2 changes: 1 addition & 1 deletion src/index.CodePipelineStatusHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const buildBitbucketBuildStatusBody = async (
return {
state,
key: `${detail.stage}-${detail.action}`,
name: `${detail.stage}-${detail.action} (${await getCurrentAccountAlias(event.account)})`,
name: `CodePipeline ${detail.pipeline} ${detail.stage}/${detail.action} (${await getCurrentAccountAlias(event.account)} @ ${event.region})`,
url: `https://${event.region}.console.aws.amazon.com/codesuite/codepipeline/pipelines/${detail.pipeline}/view`,
description: `${detail.stage}-${detail.action}`,
};
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/index.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions test/index.CodeBuildStatusHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ const event = (status: AwsLambda.CodeBuildStateType): AwsLambda.CodeBuildCloudWa
test('buildBitbucketBuildStatus InProgress', async () => {
expect(await buildBitbucketBuildStatusBody(event('IN_PROGRESS'), 'IN_PROGRESS')).toMatchObject({
description: 'my-sample-project build initiated by MyCodeBuildDemoUser at Sep 1, 2017 4:12:29 PM',
key: 'my-sample-project-8745a7a9-c340-456a-9166-edf953571bEX',
name: 'CodeBuild-my-sample-project (123456789012)',
key: 'my-sample-project',
name: 'CodeBuild my-sample-project (123456789012 @ us-west-2)',
state: 'INPROGRESS',
url: 'https://us-west-2.console.aws.amazon.com/codesuite/codebuild/123456789012/projects/my-sample-project/build/my-sample-project:8745a7a9-c340-456a-9166-edf953571bEX/?region=us-west-2',
});
Expand All @@ -147,8 +147,8 @@ test('buildBitbucketBuildStatus InProgress', async () => {
test('buildBitbucketBuildStatus Succeeded', async () => {
expect(await buildBitbucketBuildStatusBody(event('SUCCEEDED'), 'SUCCEEDED')).toMatchObject({
description: 'my-sample-project build initiated by MyCodeBuildDemoUser at Sep 1, 2017 4:12:29 PM',
key: 'my-sample-project-8745a7a9-c340-456a-9166-edf953571bEX',
name: 'CodeBuild-my-sample-project (123456789012)',
key: 'my-sample-project',
name: 'CodeBuild my-sample-project (123456789012 @ us-west-2)',
state: 'SUCCESSFUL',
url: 'https://us-west-2.console.aws.amazon.com/codesuite/codebuild/123456789012/projects/my-sample-project/build/my-sample-project:8745a7a9-c340-456a-9166-edf953571bEX/?region=us-west-2',
});
Expand All @@ -157,8 +157,8 @@ test('buildBitbucketBuildStatus Succeeded', async () => {
test('buildBitbucketBuildStatus Failed', async () => {
expect(await buildBitbucketBuildStatusBody(event('FAILED'), 'FAILED')).toMatchObject({
description: 'my-sample-project build initiated by MyCodeBuildDemoUser at Sep 1, 2017 4:12:29 PM',
key: 'my-sample-project-8745a7a9-c340-456a-9166-edf953571bEX',
name: 'CodeBuild-my-sample-project (123456789012)',
key: 'my-sample-project',
name: 'CodeBuild my-sample-project (123456789012 @ us-west-2)',
state: 'FAILED',
url: 'https://us-west-2.console.aws.amazon.com/codesuite/codebuild/123456789012/projects/my-sample-project/build/my-sample-project:8745a7a9-c340-456a-9166-edf953571bEX/?region=us-west-2',
});
Expand Down
8 changes: 4 additions & 4 deletions test/index.CodePipelineStatusHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test('buildBitbucketBuildStatus InProgress', async () => {
expect(await buildBitbucketBuildStatusBody(event('STARTED'), CodePipeline.ActionExecutionStatus.InProgress)).toMatchObject({
description: 'Prod-myAction',
key: 'Prod-myAction',
name: 'Prod-myAction (Pipeline_Account)',
name: 'CodePipeline myPipeline Prod/myAction (Pipeline_Account @ us-east-1)',
state: 'INPROGRESS',
url: 'https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/myPipeline/view',
});
Expand All @@ -47,7 +47,7 @@ test('buildBitbucketBuildStatus Succeeded', async () => {
expect(await buildBitbucketBuildStatusBody(event('SUCCEEDED'), CodePipeline.ActionExecutionStatus.Succeeded)).toMatchObject({
description: 'Prod-myAction',
key: 'Prod-myAction',
name: 'Prod-myAction (Pipeline_Account)',
name: 'CodePipeline myPipeline Prod/myAction (Pipeline_Account @ us-east-1)',
state: 'SUCCESSFUL',
url: 'https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/myPipeline/view',
});
Expand All @@ -57,7 +57,7 @@ test('buildBitbucketBuildStatus Superseded', async () => {
expect(await buildBitbucketBuildStatusBody(event('CANCELED'), CodePipeline.ActionExecutionStatus.Abandoned)).toMatchObject({
description: 'Prod-myAction',
key: 'Prod-myAction',
name: 'Prod-myAction (Pipeline_Account)',
name: 'CodePipeline myPipeline Prod/myAction (Pipeline_Account @ us-east-1)',
state: 'SUCCESSFUL',
url: 'https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/myPipeline/view',
});
Expand All @@ -72,7 +72,7 @@ test('buildBitbucketBuildStatus FAILED Manual Approval is reported as success',
}), CodePipeline.ActionExecutionStatus.Abandoned)).toMatchObject({
description: 'Prod-myAction',
key: 'Prod-myAction',
name: 'Prod-myAction (Pipeline_Account)',
name: 'CodePipeline myPipeline Prod/myAction (Pipeline_Account @ us-east-1)',
state: 'SUCCESSFUL',
url: 'https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/myPipeline/view',
});
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 59803f7

Please sign in to comment.