Using the mabl CLI

Exploring commands in the mabl CLI

This article is for new users who are unfamiliar with command-line tools. Follow the commands outlined in this article to log in to the mabl CLI, get more information on mabl CLI commands, and understand how different commands work.

Authentication

To use the mabl CLI on your local machine, run the following command:

mabl auth login

This command prompts the mabl CLI to open the mabl login page in a browser window. Take the following steps to complete authentication:

  1. Log into mabl using your usual method: username and password, Google auth, or SSO.
  2. Copy the authorization code from the browser window.
  3. Paste the authorization code in the mabl CLI.
  4. Press enter to finish logging in.

Authenticating with an API key

If you are incorporating the mabl CLI into a script, you can authenticate with an API key:

mabl auth activate-key <api-key>

Exploring the mabl CLI

The mabl CLI includes a range of commands for integrating mabl tests into your workflow. To learn more about the different commands available in the mabl CLI, run the following command:

mabl -h

The -h or --help option can be added to any mabl CLI command to get more information. For example, to learn more about commands for managing environments, run the following command:

mabl environments -h

To learn more about the available options for a subcommand, such as mabl environments update, add the -h option again. For example:

mabl environments update -h

Components of a mabl CLI command

Depending on the command that you run, you may need to include an argument or options.

Arguments

Some mabl CLI commands require arguments, which are values passed into the command. For example, to create a branch from the mabl CLI, you need to provide the name of the new branch as an argument:

mabl branches create <branch-name>

Options

Options, also known as "flags", modify the behavior of a command. Options are preceded with a hyphen or double-hyphen. For example, to return a list of DataTables from your workspace in JSON format, use the mabl datatables list command with the --output option:

mabl datatables list --output json

Mabl resource IDs

Many commands in the mabl CLI require a mabl resource ID as an argument or optional argument. For example, to trigger an ad hoc local run, you need to provide a test ID for the option --id:

mabl tests run --id <test-id>

You can obtain mabl resource IDs by running the list command. For example, run the following command to obtain mabl resource IDs for tests in your workspace:

mabl tests list

📘

For more information on the different ways to obtain mabl resource IDs for different mabl components, including tests, plans, DataTables, and environments, check out this article.

Next steps

Now that you are familiar with the basics, try triggering an ad hoc test run from the mabl CLI!