curl Command Reference for CI Scripts
curl moves bytes between a runner and a URL, scriptably and without a browser.
curl is the default HTTP client in pipelines. The trick in CI is making it fail loudly and retry sensibly instead of silently writing an error page to a file.
Common flags/usage
- -f / --fail: exit non-zero on HTTP >= 400 instead of writing the error body
- -sS: silent but still show errors (combine -s with -S)
- -L / --location: follow redirects
- -o FILE / -O: write to a named file / use the remote filename
- --retry N --retry-delay S --retry-all-errors: retry transient failures
Example
shell
curl -fsSL -o app.tar.gz \
--retry 5 --retry-delay 2 --retry-all-errors \
"https://example.com/releases/${VERSION}/app.tar.gz"
curl -fsS -H "Authorization: Bearer ${TOKEN}" https://api.example.com/v1/statusIn CI
Always pass -f so an HTTP 500 does not get piped into bash or saved as a "valid" archive, and -sS so silent mode still surfaces the real error. Key exit codes: 6 = DNS failure, 7 = connection refused, 22 = HTTP error with -f, 28 = timeout. Add --retry for flaky networks.
Key takeaways
- Use -fsSL as the default flag set: fail on HTTP errors, stay quiet, show errors, follow redirects.
- Pipe untrusted downloads through -f so error pages never reach bash or a file.
- --retry with --retry-all-errors hardens downloads against transient CI network blips.
Related guides
wget Command Reference for CI Scriptswget is a non-interactive downloader for CI. Reference for -O, -q, --tries, and --timeout, and why it fails o…
jq Command Reference for CI Scriptsjq is the command-line JSON processor for CI. Reference for -r raw output, -e exit status, --arg, and filters…
sha256sum Command Reference for CI Scriptssha256sum computes and verifies checksums in CI for download integrity. Reference for -c verify mode, --statu…
timeout Command Reference for CI Scriptstimeout caps how long a command may run in CI, preventing hangs. Reference for duration units, -k kill-after,…