Build Commands

Install dependencies and compile your code on Donkey's servers before it is uploaded, with caches and file rules.

Build commands prepare your code before it is uploaded: install dependencies, compile assets, package an application. They run on Donkey's servers, not on yours, and the files they produce are uploaded with the deployment.

Build commands aren't available on every account yet. If your project has no Build Commands page, ask us.
How a build runs
  1. Donkey checks out the commit being deployed.
  2. It runs the project's active build commands in order, each in a Docker container, with the checked-out code at /source.
  3. It uploads the result, including the generated files, to the server.

If a command fails, the deployment stops there and nothing is uploaded. Your servers keep the release they had.

Add a build command

In a project, open Build Commands and choose New build command.

ContainerThe Docker image the commands run in, chosen from the images Donkey provides. It decides which tools are installed, such as Java and Maven.
NameA label for the list and the deployment log, such as Package.
CommandsOne command per line, as you would type them in a terminal.
DescriptionWhat the command is for, for whoever reads it next.
StatusOnly Active commands run. Untick it to keep a command without running it.
# Container: Maven with java8
mvn -B -q package -DskipTests

To start a new command from an existing one, use the copy button () next to it in the list. Cache rules and file rules have one too.

Turn builds on and off

The Active Build Commands switch at the top of the Build Commands page turns building on or off for the whole project, without touching the commands. A deployment builds only when the switch is on and at least one command is active.

Cache rules

Each build starts from a clean checkout, so downloading every dependency again makes builds slow. Cache rules (Cache follow rules on the page) name files and folders to keep from one build to the next, one pattern per line:

node_modules/**
vendor/**

* matches within a folder name, ** across folders and ? one character.

Include and exclude file rules

Build file rules decide which files are uploaded once the build has run, for the servers you choose:

  • Include rules upload only the files they match. Without one, everything is uploaded.
  • Exclude rules leave out the files they match, such as source maps or the sources a build compiled.
# include: the packaged application only
target/*.jar

# exclude
**/*.map
Stacks

A stack deployment builds once and uploads the same result to every server of the stack, so the servers get identical files and the build doesn't run once per server.

When a build fails

The deployment page says why the build failed, and its Building step keeps the output of each command, also after the deployment has finished.

ErrorWhat to do
6003 A build command failedRead the Building step for the command's output, fix the command or the code, and deploy again.
4005 Build commands are disabled on this server"This server" is Donkey's, not yours: builds aren't available right now. To deploy without building, switch off Active Build Commands and deploy again.
From the repository

The build and files sections of a Donkeyfile replace the build commands, cache rules and file rules for deployments of commits that have one. A Donkeyfile can also give each step its own image and run a step only for some branches.

Still need help?

Tell us what you are trying to do and we will reply by e-mail.

Contact support