'Run Batch Builds in CodeBuild using a single buildspec file

This is the buildspec format for build-list in CodeBuild

version: 0.2

batch:
  fast-fail: false
  build-list:
    - identifier: build1
      env:
        variables:
          BUILD_ID: build1
      ignore-failure: false
    - identifier: build2
      buildspec: build2.yml
      env:
        variables:
          BUILD_ID: build2
      ignore-failure: true

Instead of giving another buildspec(build2.yml)I want to specify the commands directly in a single file.



Solution 1:[1]

You can use the inline yaml syntax instead of passing the filename. Something like this:

version: 0.2
batch:
  fast-fail: false
  build-list:
    - identifier: build1
      env:
        variables:
          BUILD_ID: build1
      buildspec: |
        version: 0.2
        env:
          shell: bash
        phases:
          build:
            commands:
              - command
      ignore-failure: true

    - identifier: build2
      env:
        variables:
          BUILD_ID: build2
      buildspec: |
        version: 0.2
        env:
          shell: bash
        phases:
          build:
            commands:
              - command
      ignore-failure: true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 awerebea