HubDocs

Guides

Automation. Run hub from scripts, CI and coding agents.

Every command works without a terminal when you give it what it would ask for. A command that needs an answer it cannot get fails with an error naming the flag to pass.

Log in without a browser

HUB_EMAIL=ci@acme.com HUB_PASSWORD="$HUB_PASSWORD" hub login
hub login --email ci@acme.com --password "$HUB_PASSWORD" --org acme

With --email or HUB_EMAIL, hub login uses the password from --password or HUB_PASSWORD. --org or HUB_ORG picks which of your orgs to use, by slug or by name.

A script creates an account only when it gives all three of --name, --org and --code, or HUB_NAME, HUB_ORG and HUB_SIGNUP_CODE. A mistyped email never creates a second account, and running the same script twice logs in the second time.

The login lasts 90 days. The CLI keeps it in ~/.config/hub-cloud/credentials.json, readable only by you. hub whoami shows the account and org, and hub logout forgets it.

Flags that skip questions

CommandFlag
hub deploy in a folder with unpushed changes--pushed or --local
hub deploy, hub app <name> redeploy--detach returns without following the build
hub app <name> logs--no-follow prints and exits
hub app <name> rm--yes keeps the data, --delete-data deletes it
hub members remove, hub leave--yes
hub validate--json

hub app <name> env set NAME asks for the value. In a script, pass NAME=value or --file.

Environment

VariableEffect
HUB_EMAIL, HUB_PASSWORDLog in with a password.
HUB_ORG, HUB_NAME, HUB_SIGNUP_CODEPick an org, or create an account.
HUB_NO_UPDATE_CHECK=1Skip the daily check for a newer CLI.

Errors and exit codes

Errors go to stderr as a code and a message, often with a hint:

error forbidden: this needs the member role
Exit codeMeaning
0Done.
1The command failed. The error says why.
3This CLI is older than Hub accepts. Update with npm install --global @hubhq/cli@latest.
130Cancelled with Ctrl-C.

hub app <name> exec exits with the exit code of the command it ran.

On this page