-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(codebuild): allow taking the artifact name from the buildspec #7384
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
feat(codebuild): allow taking the artifact name from the buildspec #7384
Conversation
This commit adds support for CodeBuild Artifacts to have names controlled by a buildspec file, allowing the use of shell scripting to sensibly name artifacts in CodeBuild projects generated from the CDK. Fixes #5955
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
@skinny85 - Hi, any chance this can get reviewed in the next week or so? It's a feature that would unblock me at work! Hopefully it's a small enough change, despite the various merges from master. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
I'll review it today - apologies for the delay @shearn89 ! |
skinny85
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the contribution @shearn89 ! I have a few small comments, and one idea I wanted to run by you.
So, when useBuildSpecName is true, we ignore the name property completely. I wonder whether a slightly different design might work here.
Currently, name is required in S3ArtifactsProps. I wonder if, instead of adding the new useBuildSpecName property, we could make name optional. If name was not provided, we will just set overrideArtifactName in the implementation to true, and pass either undefined, or some random value (like project.node.uniqueId) for name (it's optional in the CFN resource, but we need to check whether its presence is not validated by the CodeBuild backend APIs).
What do you think?
|
Hey @skinny85 - thanks for the review! I'm just about to push a commit with the proposed design change. I think it makes sense, and we shouldn't be changing any existing behaviour as the parameter is going from mandatory to optional. Given that this PR is the first time the (My TypeScript is not brilliant, so hopefully I've done it correctly! 🤞 ) |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This commit reworks the implementation to instead make `name` optional. If the `name` is not provided, `overrideArtifactName` will be set and the buildspec name will be used.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
skinny85
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shearn89 , this looks amazing. I have one last question before I merge this in.
Thanks so much!
| path: this.props.path, | ||
| namespaceType: this.props.includeBuildId === false ? 'NONE' : 'BUILD_ID', | ||
| name: this.props.name, | ||
| name: this.props.name == null ? project.node.uniqueId : this.props.name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test that this is necessary - we can't just leave this as undefined? name is optional in CfnProject.ArtifactsProperty: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-codebuild.CfnProject.ArtifactsProperty.html#name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't - I'll do so today and set it to undefined if that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, hopefully the integration tests pass!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure we're on the same page - by default, the integration tests act like snapshot tests. You need to specifically run the npm integ target to have them deployed. More info here: https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md#integration-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay! I'll run those this evening and let you know the outcome...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just ran the tests against my own account and all the aws-codebuild integration tests provision and tear down correctly, no errors visible in the CloudFormation console or build logs!
Fixing typo. Co-Authored-By: Adam Ruka <[email protected]>
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
skinny85
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic. I'm really happy with where we ended up with this feature. Thanks so much for the awesome contribution @shearn89 !
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Commit Message
feat(codebuild): allow taking the artifact name from the buildspec
This commit adds support for CodeBuild Artifacts to have names
controlled by a buildspec file, allowing the use of shell scripting to
sensibly name artifacts in CodeBuild projects generated from the CDK.
The previosuly required field
nameinS3ArtifactsPropsis now optional,and not providing it will set the
overrideArtifactNameon the underlying L1 totrue.Fixes #5955
End Commit Message
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license