Hello world
Zero to 'hello world' in five minutes:
Step 1: create your project
Create a new folder for your project.
Download the latest version of
batect
andbatect.cmd
from the releases page, and copy these scripts into your project folder.Note that you only need the scripts - you don't need to download
batect.jar
.If you're on Linux or macOS, make sure the script is executable: run
chmod +x batect
.
Step 2: define your environment and tasks
Create a file called
batect.yml
and add this container definition:batect.ymlcontainers:
my-container:
image: alpine:3.11.3This container defines the environment our task will run in. In this case, we're using an Alpine Linux image.
After that container definition, add a task:
batect.ymlcontainers:
my-container:
image: alpine:3.11.3
tasks:
say-hello:
description: Say hello to the nice person reading the Batect documentation
run:
container: my-container
command: echo 'Hello world!'This task defines what to do when the task is run. In this case, it'll just print a "Hello world!" message.
Step 3: run the task
Open a terminal, change to the project folder and run
./batect --list-tasks
. You should see output similar to the following:Available tasks:
- say-hello: Say hello to the nice person reading the Batect documentation--list-tasks
is available in every Batect project, and makes it easy for your team to discover what tasks are available to them.Now let's run the task with
./batect say-hello
. You should see output similar to the following:Running say-hello...
my-container: running echo 'Hello world!'
Hello world!
say-hello finished with exit code 0 in 1.2s.
Where next?
- The tutorial introduces the main concepts of Batect through a simple sample application
- The sample projects show Batect in a number of real-world scenarios