Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 229
Msv Avatar asked May 16 '26 12:05

Msv


2 Answers

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
like image 163
awerebea Avatar answered May 18 '26 19:05

awerebea


buildspec is an optional property of batch/build-list, from the AWS documentation:

If this parameter is not specified, the current buildspec file is used.

So you can add phases to the buildspec as you would for a non-batch build, example from the userguide:

batch:
  build-list:
    - identifier: build1
      env:
        compute-type: BUILD_GENERAL1_SMALL
    - identifier: build2
      env:
        compute-type: BUILD_GENERAL1_MEDIUM

phases:
  build:
    commands:
      - echo 'file' > output_file

artifacts:
  files:
    - output_file
like image 23
Oleg Avatar answered May 18 '26 19:05

Oleg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!