Jobs
Jobs form a crucial component of any workflow. This document will describe the features of jobs as well as provide examples of using them.
Overview
Each workflow is made of a series of jobs, which are separate tasks that are to be performed on a runner. Using jobs we can:
- Run a series of command-line applications in the form of steps.
- Automate tools and applications.
- Form complex dependencies between jobs.
The jobs for a particular workflow may be found by clicking on the workflow in a project's page.
Status
Jobs may have a particular status:
Status | Description |
---|---|
Passed | Job has completed succesfully |
Failed | Job has failed |
Pending | Job is in progress |
Idle | Job has not started |
Configuration Examples
Concurrent jobs
The following example shows a single workflow that will run two jobs in parallel.
By default, all jobs will run in parallel.
To create jobs, you need a jobs:
section in bbx./config.yaml
.
Each job will require a unique name, in the provided example the jobs have been named example-build
and example-test
.
Since each job is independent of the other, they will run in parallel.
runners:
example-runner:
image: work1-virtualbox:5000/ubuntu-generic
jobs:
example-job1:
runner: example-runner
steps:
- run:
name: Say Hello World 1
command: |
echo "Hello World 1"
example-job2:
runner: example-runner
steps:
- run:
name: Say Hello World 2
command: |
echo "Hello World 2"
workflows:
workflow-example:
jobs:
- example-job1
- example-job2
Dependent jobs
Jobs may require the completion of another job, such as when running a build and then testing that build. Dependencies between jobs can be created through the depends
.
The following example shows a single workflow that will run three jobs that depend on each other.
To create a dependency, you need to include a depends
section in the job, followed by a list of the jobs the current job is dependent on.
In this case, example-test-1
and example-test-2
both depend on example-build
.
Once example-build
successfully completes, both the test jobs that depend on it can run concurrently (the two test jobs in this example do not depend on each other).
runners:
example-runner:
image: work1-virtualbox:5000/ubuntu-generic
jobs:
example-build:
runner: example-runner
steps:
- run:
name: Running a build
command: echo "Running a build"
example-test-1:
runner: example-runner
depends:
- example-build
steps:
- run:
name: Running a Test
command: echo "Running the first test"
example-test-2:
runner: example-runner
depends:
- example-build
steps:
- run:
name: Running a Test
command: echo "Running the second test"
workflows:
workflow-example:
jobs:
- example-build
- example-test-1
- example-test-2