Exec
Run a command in a workspace.
POST /v1/workspaces/{id}/execRuns one command line in the workspace and answers once it has ended and what it changed is stored. The guide Running commands explains how to use it.
Request
| Field | |
|---|---|
command | Required. A bash command line, 1 to 100,000 characters. Several lines are fine |
cwd | Where the command starts: /workspace or a directory below it. Default /workspace |
timeoutMs | How long the command may run, in milliseconds. At most, and by default, 30,000 |
{ "command": "ls -la && cat README.md", "cwd": "/workspace/app", "timeoutMs": 10000 }Response
200 whenever the command ran, whatever its exit code.
{
"stdout": "...",
"stderr": "",
"exitCode": 0,
"cwd": "/workspace/app",
"executor": "shell",
"timedOut": false,
"truncated": { "stdout": false, "stderr": false }
}| Field | |
|---|---|
stdout, stderr | What the command wrote, up to 1 MiB each |
exitCode | As in bash: 0 for success. 124 when it ran out of time, 126 when it ran too many commands, 127 for a command that isn't there |
cwd | Where the command ended. Pass it as cwd to go on from there |
executor | Where the command ran. Always shell, the emulated shell, for now |
timedOut | Whether it was stopped for running too long |
truncated | Whether stdout or stderr was cut at the limit |
Errors
| Error | When |
|---|---|
400 invalid_request | No command, a command too long, or a cwd outside /workspace |
404 not_found | No such workspace in your organization |
503 store_unavailable | The workspace's storage isn't configured or can't be reached |
500 internal | Something failed in the service or in the storage behind it, such as the storage refusing requests for a moment. Try again |
Order
Commands on one workspace run one after another, in the order they arrive. A command sees everything written to the workspace before it started, by any client, and its answer comes once its own changes are stored.