Msv
Msv

Reputation: 1371

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.

Upvotes: 3

Views: 2478

Answers (2)

Oleg
Oleg

Reputation: 25008

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

Upvotes: 1

awerebea
awerebea

Reputation: 66

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

Upvotes: 5

Related Questions