I'm building a project that puts all of it's files in a 'dist' folder, and running it through CodeBuild. I'm trying to get it to put all of the files and folders in 'dist' into the root of the s3 bucket, but I'm having trouble figuring out how to make that work.
My 'dist' folder looks something like this:
- index.html
- somecssfiles.css
- fonts/
- - some fonts or w/e
- js/
- - some javascript files
I've tried a lot of different stuff, but can't seem to get it to just drop 'dist/*' into the root of the s3 bucket. Here's the current iteration of my artifacts
property in the buildspec.yml file:
artifacts:
files:
- '*'
discard-paths: yes
base-directory: 'dist'
I thought that would probably work, but it ignores the folders. Any help is appreciated, thanks for reading.
The "discard-paths: yes" is what throws away your directory structure. It essentially flattens your artifact set. If (like me) you only want to throw away paths up to your artifact folder, put that full path in the "base-directory" field.
If the build details page is not displayed, in the navigation bar, choose Build history, and then choose the Build run link. The link to the Amazon S3 folder is under the Artifacts upload location. This link opens the folder in Amazon S3 where you find the messageUtil-1.0. jar build output artifact file.
Q: Can I encrypt the build artifacts stored by CodeBuild? Yes. You can specify a key stored in the AWS Key Management Service (AWS KMS) to encrypt your artifacts.
Artifacts is a property of the AWS::CodeBuild::Project resource that specifies output settings for artifacts generated by an AWS CodeBuild build.
I think you're missing a piece - it's not clear but you need to specify the path in your Codebuild template with the following artifacts:
artifacts:
files:
- '**/*'
base-directory: 'dist'
And then ensure that in the "Artifacts" section of your codebuild project, you specify the S3 bucket normally, but add the "optional" name parameter to be /
This sets the output to the root of the S3 directory - see https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectArtifacts.html#CodeBuild-Type-ProjectArtifacts-name
If type is set to S3, this is the name of the output artifact object. If you set the name to be a forward slash ("/"), the artifact is stored in the root of the output bucket.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With