Skip to main content
Version: 0.6.0

Build

info

A task defined under the build: directive is referred to as build task

A build task can invoke one or many build/cli tools to build a part of a project. Build tasks are composable and can depend on each other with a preserving build order. By monitoring and hashing the inputs of a task, bob makes sure that a task is executed only if needed.

Take a look at this task which builds an arbitrary Go project:

## bob.yaml
dependencies: [ go_1_19 ]
build:
build:
input: |-
main1.go
cmd: |-
go build -o run
target: run

A task can be executed using the bob cli

bob build taskname

As build is the default taskname, the task above can also be executed by typing bob build

The main components of a task are:

  • input - defines whether a task needs a rebuild. By default, the entire directory is considered (*). For performance reasons it's recommended to keep the number of inputs as small as possible.
  • cmd - cmds to execute when an input file changes. It's possible to run multiple cmds sequentially for a task.
  • target - defines the output of a task. Can be a single file, entire directory or even a docker image.

Pipelines

Often tasks need to be executed in a certain order. It's easy to create a pipline by using the dependsOn keyword.

## bob.yaml
build:
build:
...
dependsOn:
- codegen
codegen:
...

Cache

By default bob stores targets in a local cache and loads them if required. A remote cache is WIP. Whenever you change branches back and forth the cache saves you from unnecessary rebuilds by taking the targets from the cache.

Always Rebuild

By default build tasks only execute when any of their inputs or the task description changes. To make a build task execute always use the rebuild keyword. It accepts the values [always, on-change], defaults to on-change.

## bob.yaml
build:
build:
...
rebuild: always

You can also use the cli flag bob build taskname --no-cache to set rebuild: always for an entire pipeline. Additionaly it also stops loading & saving targets from the cache.

Look into the api reference for more details of how to use build tasks.