Version: 4.11

Custom Commands

The idea of custom commands is that someone on a team defines a set of useful commands and stores them in the devspace.yaml, then commits and pushes this config to the code repository. Now, others can run these custom commands without having to remember all the details or having to read through endless pages of documentation.

Custom commands are being shared in the commands section of devspace.yaml:

# File: devspace.yaml
images:
default:
image: john/backend
commands:
- name: debug-backend
command: "devspace dev -i --profile=debug-backend"
profiles:
- name: debug-backend
patches:
- op: replace
path: images.default.entrypoint
value: ["npm", "run", "debug"]
note

Custom commands can be used for more than just running devspace commands, e.g. they can run any other script or command, set environment variables etc. If you are familiar with the scripts section of the package.json for Node.js, you will find that devspace run [name] works pretty much the same way as npm run [name]

The above example configuration would allow everyone to run the custom command debug-backend like this:

devspace run debug-backend

And devspace run would execute the following command internally:

devspace dev -i --profile=debug-backend
Interactive Commands

Custom commands proxy input and output streams, so you can even share interactive commands such as devspace enter.

Configuration

name

The name option is mandatory and expects a string with name that serves as an alias for the command provided in the command option.

command

The command option is mandatory and expects a string with an arbitrary terminal command.

While you can run any devspace command, you can also run other commands (if installed), set environment variables or use bash style expressions such as &&, || or ;. To ensure that many of your team mates can run the command on any platform, it is highly recommended to keep your command expressions as simple as possible.

Cross-Platform

Write all commands in bash style. DevSpace is using a library to make them cross-platform executable.

Useful Commands

devspace list commands

Run this command to list all custom commands that are configured:

devspace list commands