I have a large monorepo with many projects in it. I want to have many build jobs, each using a buildspec in the relevant tree in the repo.
For example, I have a lambda function called Email, and a java application called Web. The source trees for each are siblings, and I want to put a buildspec in each and have different jobs use the different buildspec.yml files.
I can't find a way to make this work, as the name of the buildspec file specified in the job must be at the root of the repo (it's a git repo).
Store a buildspec file somewhere other than the root of your source directory, such as config/buildspec. yml or in an S3 bucket. The S3 bucket must be in the same AWS Region as your build project. Specify the buildspec file using its ARN (for example, arn:aws:s3:::my-codebuild-sample2/buildspec.
A buildspec is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build. Without a build spec, CodeBuild cannot successfully convert your build input into build output or locate the build output artifact in the build environment to upload to your output bucket.
AWS CodeBuild now supports the bash and CMD shell environments for executing commands and scripts. The bash shell is available for machines hosting versions of Amazon Linux or Ubuntu, and the CMD shell is available on machines hosting versions of Microsoft Windows Server.
Artifacts is a property of the AWS::CodeBuild::Project resource that specifies output settings for artifacts generated by an AWS CodeBuild build.
You can specify an alternate buildspec location in the buildspec
or buildspecOverride
parameter to Create/UpdateProject or StartBuild.
The buildspec path is relative to the root of your Git repo. So you can use, e.g., ./subdir/buildspec.yml
You can find the documentation here: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-name-storage
There's now a way to change the buildspec path of a CodeBuild project via the console. Edit a project (console url is https://[region-name].console.aws.amazon.com/codebuild/home?region=[region-name]#/projects) and under "Environment: How to build" there's a parameter called "Buildspec name". Set that to the path of the buildspec.yml file relative to the root directory.
This is now possible when using the console as well, but they don't make it easy to find.
Use the buildspec.yml in the source code root directory
option as normal and save the build project.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