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.
Use this image as shown here:
- Mounts current working directory into
/projectwithin the container
/projectas working dir
devspace deployinside working dir
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).
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
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.
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 allows you to split up the build and deployment process into two separate commands:
To run unit or integration tests in your CI/CD pipeline, you have multiple options:
- Split up build and deployment command and run tests before after or in between the commands
- Define hooks that execute commands before/after certain image builds or deployments