Skip to main content
Version: 6.x (Latest)

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
image: john/backend

debug-backend: |-
devspace dev $@

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
devspace run debug-backend -n my-namespace

And devspace run would execute the following commands internally:

devspace dev
devspace dev -n my-namespace
-- End of Options Separator

The -- between the command name and the additional flags for the command tells your terminal that the arguments and flags that follow after the -- do not belong to devspace run and should not be parsed. It is not required but often helpful to use -- when executing commands using devspace run.

Interactive Commands

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


commands required <command_name>:object

Commands are custom commands that can be executed via 'devspace run COMMAND'. These commands are run within a pseudo bash that also allows executing special commands such as run_watch or is_equal.

<command_name> required string

Name is the name of a command that is used via devspace run NAME

section required string

Section can be used to group similar commands together in devspace list commands

command required string

Command is the command that should be executed. For example: 'echo 123'

args required string[]

Args are optional and if defined, command is not executed within a shell and rather directly.

appendArgs required boolean false

AppendArgs will append arguments passed to the DevSpace command automatically to the specified command.

description required string

Description describes what the command is doing and can be seen in devspace list commands

internal required boolean false

Internal commands are not show in list and are usable through run_command

after required string

After is executed after the command was run. It is executed also when the command was interrupted which will set the env variable COMMAND_INTERRUPT to true as well as when the command errored which will set the error string to COMMAND_ERROR.

Useful Commands

devspace list commands

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

devspace list commands

devspace run dependency1.command

You can run a command defined in one of the dependencies of the current project like this:

devspace run [dependency].[command] [command-flags-and-args]
Working Directory

When running a command of a dependency, DevSpace will use the root folder of the dependency as current working directory when executing the command.