10

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).

3 Answers3

4

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

Unsigned
  • 8,731
  • 4
  • 40
  • 67
  • Well, whadda ya know. I either didn't find that specific page, or managed to completely gloss over the location mention in the SECOND paragraph. Thanks for pointing it out! – Gizmo Gadget Guy Aug 18 '17 at 18:27
  • I am not finding, how to use a different file name for build specification. So, I use `buildspec-dev.yml`. Now, I want to say codeBuild that use `buildspec-dev.yml` for build commands. The above link doesnt say how to have a different file name. Can anyone direct me to use a different buildSpec file name in the console? – Lakshman Diwaakar Sep 15 '17 at 04:09
  • @LakshmanDiwaakar You cannot do this in the console currently. You must use the API or CloudFormation. – Unsigned Sep 15 '17 at 07:21
  • Exactly, that is what I am looking for. But the above does not state anything clearly. Do you know, how to override the behaviour in console? – Lakshman Diwaakar Sep 15 '17 at 07:22
  • 1
    @LakshmanDiwaakar As I said above. This *cannot* currently be done via the console. You *must* use the API (or CloudFormation.) – Unsigned Sep 15 '17 at 08:52
  • Ah. Gotcha!! I was looking for the console. – Lakshman Diwaakar Sep 15 '17 at 08:53
2

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.

skeller88
  • 2,802
  • 1
  • 24
  • 29
1

This is now possible when using the console as well, but they don't make it easy to find.

  • When you are first configuring the build, the console will not give you an option to specify a custom buildspec file name / location. Instead, in the "Environment: How to build" section choose the Use the buildspec.yml in the source code root directory option as normal and save the build project.

FirstConsoleEdit

  • Then you will be able to go back and re-edit the project. Once you do so, you will see that the "Environment: How to build" section now has a link called "Update build specification".

CodeBuildReEdit

  • Click the "Update build specification" link and a section will open up that includes a "Buildspec Name" input where you can enter the custom name of / path to your buildspec file.

CodeBuildReEditSuccess

lemmingworks
  • 149
  • 1
  • 5