Skip to content
Latchkey

wget Command Reference for CI Scripts

wget downloads files over HTTP, HTTPS, and FTP without needing a terminal.

wget is the other ubiquitous downloader. It returns non-zero on server errors by default, which is convenient, but its exit codes are coarser than curl.

Common flags/usage

  • -O FILE: write to a specific file (-O- writes to stdout)
  • -q: quiet, no progress output
  • --tries=N: retry up to N times (0 means infinite)
  • --timeout=SECS: cap DNS, connect, and read time
  • -c: resume a partial download

Example

shell
wget -q --tries=5 --timeout=20 \
  -O tool.bin "https://example.com/${TOOL}/download"
wget -qO- https://get.example.com/install.sh | sh

In CI

wget exits 8 on an HTTP error like 404 and 4 on a network failure, so a failed download stops the job without -f. Note that -O with multiple URLs concatenates them into one file and silently corrupts archives. Minimal images (alpine) often lack wget, so prefer curl or install it.

Key takeaways

  • wget fails on HTTP errors by default, so a 404 stops the job without an extra flag.
  • Use --tries and --timeout so a hung mirror does not stall the runner.
  • Avoid -O with multiple URLs; it merges them into one corrupt file.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →