Skip to main content

Mongo

Example YAML configuration for a project requiring a Mongo as a pipeline dependency.

Scenario

User is looking to create a pipeline that can integrate with an ephemeral Mongo instance.

Services

Services YAML block can be used with stages and steps pipelines. This example uses a basic steps configuration.

The following pipeline concepts are being used in the pipeline below:

tip

Pipeline must be stored in base of repository as .vela.yml or .vela.yaml

It is recommended to pin image: versions for production pipelines

version: "1"
services:
- name: mongo
image: mongo:latest
pull: always

steps:
- name: check status
image: mongo:latest
pull: always
commands:
# sleeping can help ensure the service adequate time to start
+ - sleep 15
- /bin/mongosh --host mongo --eval 'db.runCommand("ping")'

Detach

If you're looking for more granular start time for the container you can add a detach flag within stages and steps pipelines.

The following pipeline concepts are being used in the pipeline below:

tip

Pipeline must be stored in base of repository as .vela.yml or .vela.yaml

It is recommended to pin image: versions for production pipelines

version: "1"

steps:
- name: mongo
image: mongo:latest
detach: true

- name: check status
image: mongo:latest
commands:
# sleeping can help ensure the service adequate time to start
+ - sleep 15
- /bin/mongosh --host mongo --eval 'db.runCommand("ping")'