Skip to main content
Version: 5.17

CI/CD Integration

DevSpace is designed to work in non-interactive environments the same way it does in interactive environments. To use DevSpace inside a CI/CD pipeline, simply install it as part of your pipeline or start the pipeline with a VM or container image that already contains DevSpace and run any of the DevSpace commands.

Docker Image#

DevSpace provides an official Docker image that can be found on Docker Hub. The Dockerfile for this image is available on GitHub.

Use this image as shown here:

docker run devspacesh/devspace devspace [command] [args]

Example: Get Version#

docker run devspacesh/devspace devspace --version

Example: Deployment#

docker run -v ${PWD}:/project -w /project devspacesh/devspace devspace deploy
  1. Mounts current working directory into /project within the container
  2. Sets /project as working dir
  3. Runs devspace deploy inside working dir

Example: Start Interactive Terminal Session#

docker run -it -v ${PWD}:/project -w /project devspacesh/devspace

Deployment Tips#

Avoid Pickers#

If you want to run commands such as devspace enter, make sure you specify a label selector using -l, a container using -c etc. to make sure DevSpace can find the right pod/container without having to ask you to select one (which would lead to your pipeline getting stuck).

--wait Flag#

DevSpace is configured to deploy and terminate when you run devspace deploy. In CI/CD pipelines, it is common to wait until the deployment is actually up and running before continuing the pipeline. You can achieve this by using --wait:

devspace deploy --wait --timeout=120

The above command will wait until the desired number of pods is created for all ReplicaSets and until none of the pods are failing anymore. If this is not achieved within the number of seconds specified in --timeout, DevSpace will exit with a fatal error.

Define Profiles#

It is often useful to define profiles in devspace.yaml for staging, review or production deployments using CI/CD. You can deploy a project using such a profile using the -p / --profile flag:

devspace deploy -p production

Separate Build & Deploy#

DevSpace allows you to split up the build and deployment process into two separate commands:

devspace build # Build, tag and push images
devspace deploy --skip-build # Deploy project without rebuilding images

Run Tests#

To run unit or integration tests in your CI/CD pipeline, you have multiple options: