Operations
| Operation | Description |
|---|---|
Shell.Run | Runs a command with arguments in the build container, in order with the other steps. Arguments are passed as a list with no shell parsing. Fails on a non-zero exit code unless AllowFailure(). Returns a CommandStep (Value, ExitCode, Json(path); fluent InDirectory, WithTimeout, WithEnv, AllowFailure, Quiet). Signature: Run(string command, params string[] args). This is the escape hatch for one-off commands that have no ANDO operation. Prefer a first-party operation (Dotnet., Npm., Http.Get, Git.* and so on) when one exists. |
Shell.Bash | Runs a script with bash -euo pipefail -c in the build container, for pipes, redirection and sourcing helper scripts. Returns a CommandStep. Signature: Bash(string script). |
Operation Details
Shell.Run
source
Runs a command with arguments in the build container, in order with the other steps. Arguments are passed as a list with no shell parsing. Fails on a non-zero exit code unless AllowFailure(). Returns a CommandStep (Value, ExitCode, Json(path); fluent InDirectory, WithTimeout, WithEnv, AllowFailure, Quiet). Signature: Run(string command, params string[] args). This is the escape hatch for one-off commands that have no ANDO operation. Prefer a first-party operation (Dotnet., Npm., Http.Get, Git.* and so on) when one exists.
Shell.Run("zip", "-qr", "../web.zip", ".").InDirectory("artifacts/web");Shell.Bash
source
Runs a script with bash -euo pipefail -c in the build container, for pipes, redirection and sourcing helper scripts. Returns a CommandStep. Signature: Bash(string script).
Shell.Bash("source scripts/lib/deploy-gates.sh && require_spa_build artifacts/web");Overview
Shell.Run and Shell.Bash register a step that runs a command in the build container, in order with the other steps. They are the escape hatch for one-off commands that have no ANDO operation. When a first-party operation exists (Dotnet.*, Npm.*, Http.Get, Git.*, Docker.Build and so on), use it instead: it understands the tool’s options, installs prerequisites and reports better errors. The step fails the build on a non-zero exit code unless you call AllowFailure().
Both return a CommandStep. Its output can be read at execution time by later steps (see the Ando provider page, “Step model”).
Hook scripts have a different Shell global (Shell.RunAsync). The operations on this page are for build.csando.
Example
// Use a helper script as a gate (zipping and copying have Archive.Zip and Files.Copy)
Shell.Bash("source scripts/lib/deploy-gates.sh && require_spa_build artifacts/web");
// Read the output later, at execution time
var version = Shell.Run("cat", "VERSION").Quiet();
Ando.Report("version", () => version.Value);
Notes
Shell.Runpasses arguments as a list, with no shell parsing. UseShell.Bashfor pipes, redirection and sourcing scripts.Shell.Bashrunsbash -euo pipefail -c <script>, so a failing command in a pipeline fails the step.InDirectory(path): relative paths are relative to/workspace.WithTimeout(TimeSpan): the default is 5 minutes, or the value set withAndo.CommandTimeout.WithEnv(name, value)sets an environment variable for this command only.AllowFailure()lets the build continue on a non-zero exit. CheckExitCodein a laterAndo.WhenorAndo.Require.Quiet()captures the output without printing it.Valueis the trimmed stdout. ReadingValue,ExitCodeorJson(path)before the step ran throws.- The image
mcr.microsoft.com/dotnet/sdk:10.0(Ubuntu 24.04) has curl, tar, openssl, git and bash, but not zip or unzip. Install them in a step if you need them.