Developer Resources · CLI
CI and scripts
Run the Monime CLI without a browser using an access token, read JSON or YAML output, and handle exit codes in scripts and CI pipelines.
Browser login is for people. On build servers and in scripts, give the CLI an access token through the environment, turn off prompts, and read structured output.
Authenticate with an access token
Create an access token
In the dashboard, open Developer → Access Tokens and create a token with only the permissions your pipeline needs. See Personal Access Tokens.
Store it as a secret
Save the token in your CI provider's secret store, and expose it to the job as MONIME_ACCESS_TOKEN.
Name the Space
Pass --space, or set MONIME_CORE_SPACE, so the job does not depend on a saved configuration.
export MONIME_ACCESS_TOKEN=… # from your CI provider's secret store
monime space list --space spc-k6Em1Aap25VZ8oWg7ajhxHX3JqF -o jsonMONIME_ACCESS_TOKEN takes the place of stored logins: when it is set, the CLI uses it instead of the Monimeer you logged in as.
Example: GitHub Actions
jobs:
check:
runs-on: ubuntu-latest
env:
MONIME_ACCESS_TOKEN: ${{ secrets.MONIME_ACCESS_TOKEN }}
MONIME_CORE_SPACE: ${{ vars.MONIME_SPACE_ID }}
MONIME_NO_UPDATE_NOTIFIER: "1"
steps:
- name: Install the Monime CLI
run: |
curl -fsSL https://cli.monime.io/install.sh \
| MONIME_NO_MODIFY_PATH=1 sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Check access
run: monime status -o jsonPrompts
The CLI never prompts when it is not attached to a terminal. In a terminal, add --quiet (or set MONIME_CORE_DISABLE_PROMPTS=true) to use default answers instead; a command that needs an answer and has no default fails rather than waiting.
Machine-readable output
Commands that print data accept -o (--output):
| Format | Use it for |
|---|---|
table | Reading in a terminal (the default) |
wide | A table with extra columns |
json | Scripts and tools such as jq |
yaml | Config files and human-readable diffs |
# The IDs of every Space you belong to
monime space list -o json | jq -r '.[].id'
# The ID of the active Space
monime space list -o json | jq -r '.[] | select(.active) | .id'Add --no-headers to table output when you pipe it into tools such as awk or cut.
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | The command failed |
2 | Usage error, such as an unknown flag or a missing argument |
4 | Authentication is needed: you are not logged in, the login expired, or the access token was rejected |
130 | Cancelled, for example with Ctrl+C |
if ! monime status > /dev/null 2>&1; then
echo "Log in with: monime login" >&2
exit 1
fiUseful environment variables
| Variable | What it does |
|---|---|
MONIME_ACCESS_TOKEN | Authenticate with this access token instead of a stored login |
MONIME_CORE_SPACE | The Space to operate in |
MONIME_ACTIVE_CONFIG | The named configuration to use |
MONIME_CORE_DISABLE_PROMPTS | Set to true to turn off prompts |
MONIME_CORE_VERBOSITY | Log level on stderr: debug, info, warning, error or none |
MONIME_CONFIG_DIR | The folder the CLI keeps its configurations in |
MONIME_NO_UPDATE_NOTIFIER | Set to 1 to turn off the new-release notice |
Every property also has its own variable; see Configuration.