Contact Free trial Login

Anypoint Platform CLI 2.x

Anypoint Platform provides a scripting and command line tool for both Anypoint Platform and Anypoint Platform Private Cloud Edition. The CLI supports both interactive shell and standard CLI modes, and works with:

Prerequisites

  • NodeJS, and NPM (Node’s package manager) installed in your machine.
    Go to the NodeJS download page to get both resources.

  • Git version management system on your computer.
    Go to the Git download site to get this resource.

Installation

Depending on the configuration of your system, you might have to run these commands using administrator’s credentials.

$ npm install -g anypoint-cli@2.3.2

If during the installation process, npm throws a fatal: read error: Invalid argument error, make sure that the git client installed on your computer, and that the git protocol is not blocked by your firewall or network.

Reference

Every instance of Anypoint-CLI takes any of the following options:

Parameter Description Required

username

Your Anypoint Platform username.

You can also pass this value using a the environment variable export ANYPOINT_USERNAME=<name>

Yes

password

Your Anypoint Platform password.

You can also pass this value using the environment variable export ANYPOINT_PASSWORD=<pwd>

Yes

organization

Your organization within Anypoint Platform.

You can also pass this value using the environment variable ` export ANYPOINT_ORG=<name>`

No

environment

Your Anypoint environment.

You can also pass this value using the environment variable export ANYPOINT_ENV=<name>

No

host

The host of your Anypoint Platform Installation.
By default, this value points to https://anypoint.mulesoft.com.
If you are using Anypoint Platform Private Cloud Edition make sure to pass the address where you are hosting the platform. If you are using Anypoint Platform EU Cloud, make sure you pass your EU complaint URL.

You can also pass this value using a dedicated environment variable ANYPOINT_HOST=<name>

No

bearer

Instead of passing your username and password, you can choose to pass the token for your account.
You can get the token for your account by hitting the https://anypoint.mulesoft.com/accounts/login endpoint with your username and password to get your bearer value.

Your session expires when the token bearer expires.
If you send both username and password, and the token bearer, the CLI prioritizes the bearer login.

No

Usage

Credentials File

The recommended way of passing these options to your Anypoint Platform CLI installation is using the credentials file located inside the ./anypoint/ directory, which is not automatically created during installation. Follow these steps to create your credentials file:

  1. Create a directory called .anypoint in the ~/ directory for Linux and OSx, or C:\Users\USERNAME \ in Windows.

  2. Navigate to your .anypoint directory and create a blank file named credentials with the following structure:

    {
     "default": {
      "username": "yourAnypointUserName",
      "password": "yourAnypointPassword",
      "organization": "",
      "environment": "",
      "host": ""
     },
     "otherProfile": {
      "username": "",
      "password": "",
      "organization": "",
      "environment": "",
      "host": ""
     }
    }

    Note that the "default" profile is used unless the ANYPOINT_PROFILE environment variable is set:

    > export ANYPOINT_PROFILE="otherProfile"
    > anypoint-cli

Then run the anypoint-cli command without any options:

> anypoint-cli

Dedicated Environment Variables

If you choose to pass the credentials when running Anypoint-CLI, we strongly recommend passing both parameters as environment variables: ANYPOINT_USERNAME and ANYPOINT_PASSWORD.

> export ANYPOINT_USERNAME="username"
> export ANYPOINT_PASSWORD="password"
> anypoint-cli

CLI Options

As instructed above, the username and password parameters are required. However, if you choose to pass your username, Anypoint Platform CLI prompts for your password.

> anypoint-cli --username="user"
Password: ****

Passing Commands

After setting up a proper way to access Anypoint Platform from the CLI, you can start passing commands.
See Anypoint Platform CLI 2.x List of Commands for instructions on how to use them.

Considerations

A few considerations to keep in mind while using Anypoint-CLI:

  1. Environment variables override credentials file parameters and Command line parameters override environment variables.
    If you don’t pass a command line parameter, the default profile properties are used.

  2. If you don’t set an environment, you will be automatically sent to production.

  3. Your Anypoint session expires based on the Default session timeout configured in your Master Organization’s settings.

  4. Anypoint-CLI works with autocomplete. You can start typing the name of the command or parameter and hit tab for an autocomplete, or double tap tab for a list of all possible options.