It is possible to specify multiple images for your job. Specify multiple images if, for example, you need to use a database for your tests or for some other required service. In a multi-image configuration job, all steps are executed in the container created by the first image listed. All containers run in a common network and every exposed port will be available on localhost from a primary container.
jobs:
build:
docker:
# Primary container image where all steps run.
- image: buildpack-deps:trusty
# Secondary container image on common network.
- image: mongo:2.6.8-jessie
command: [mongod, --smallfiles]
working_directory: ~/
steps:
# command will execute in trusty container
# and can access mongo on localhost
- run: sleep 5 && nc -vz localhost 27017
Commands
A command defines a sequence of steps to be executed in a job, enabling you to reuse a single command definition across multiple jobs.
version: 2.1
commands:
sayhello:
description: "A very simple command for demonstration purposes"
parameters:
to:
type: string
default: "Hello World"
description: "bla"
steps:
- checkout // just a possibility
- restore_cache:
- keys:
- //...
- run: echo << parameters.to >>
- run: // can be second run
- save_cache:
- keys: // ...
- paths: // ...
Jobs
With jobs, we can automate common behaviour using our commands described previously and they will be used in the workflows section of the CircleCI configuration.
jobs:
my-job-name:
description: >
Uses circleci/aws-ecr to build and publish the docker images.
Runs kubectl rollout restart deployment/NAME afterwards to refresh the latest tag on cluster.
executor: <<parameters.executor>>
parameters:
executor:
description: executor to use for this job
type: executor
default: default
repo:
description: The ecr repo to push the docker images.
type: string
tag:
description: Some descr
type: string
default: "latest,${CIRCLE_SHA1}"
eks_account_id:
description: Some descr
type: env_var_name
default: EKS_ACCOUNT_ID