Jelastic CLI Overview

The Jelastic command-line interface (CLI) is designed to simplify interaction with your Cloud Platform account, allowing you to execute required commands via your local machine’s terminal. It can handle the vast majority of available operations remotely, complementing the wide stack of capabilities provided via the dashboard and Jelastic API.

Jelastic CLI logo

The main benefit here is the advanced and comparatively simple automation tools that CLI provides to developers. Simple text commands can be easily grouped into scripts and, in such a way, mold a powerful mechanism for accomplishing various objectives: from the most common and frequent tasks' automation to monitoring of apps and managing complex DevOps processes.

So, let’s start with the Jelastic CLI installation and reveal some key points of its usage before proceeding further.

Subsequently, you can dive deeper with the Jelastic CLI tutorials on particular operations.

CLI Installation

In order to install the Jelastic CLI at your local machine, you need to run just a single line of code via your terminal:

1
curl -s ftp://ftp.jelastic.com/pub/cli/jelastic-cli-installer.sh | bash

Notes:

  • please ensure you have Java of the 1.7 version or higher installed beforehand
  • in case you are using Windows OS, you need to get the Unix-like environment installed first (e.g. Cygwin) and run all the appropriate commands within it

Consequently, the Jelastic CLI will be installed to the dedicated jelastic folder at your home directory. The structure of the folders and bash scripts inside represents the hierarchy of Jelastic API, which results in a complete similarity of the corresponding working processes, so you can quickly get used to our CLI.

Getting Started

The base of the Jelastic CLI is represented with an executable .jar archive and some pre-configured commands (bash scripts) for operating. With the help of these commands, you are able to monitor, control and automate your environment’s lifecycle.

1. To get started, the authentication should be passed. It is called automatically on the first CLI command use, e.g.:

CLI authentication

Just follow the appearing questionnaire, specifying the asked values:

  • Platform URL - Jelastic installation URL in the app.{hoster_domain} format
  • Email - email (login) bound to your account
  • Password - your account password

If the entered data is correct, you’ll see the Jelastic logo and version of the currently used platform.

Tip: The authentication can also be initiated manually. For example, if you need to switch the current session and log in as another user or at a different Jelastic installation. Use the following command:

1
~/jelastic/users/authentication/signin --login  {email} --password  {password} --platformUrl  {platformUrl}

Here, the values in braces should be substituted with the corresponding account parameters (described above).

CLI manual authentication

The “result”: 0 property within the received response (circled in the image above) means that the operation has passed successfully and without errors. Such behavior stands for all of the commands you run.

2. The information on the actual user session (i.e. platform address and your credentials) is stored within the automatically generated ~/.config/jelastic/jelastic.properties file. It is automatically fetched when necessary, allowing you to concentrate on performed operations with no repetitive authentication steps required.

By default, the CLI command is considered successfully executed even if the called API method returns an error. You can change this behavior with the jelastic.non_zero_exit_code parameter added to the configuration file. It defines if the CLI command should respond with zero code as usual (false - default value) or with a non-zero code when the executed API method returns an error (true).

3. In case you are new to our API and need details on its command-line interface structure, you can access the embedded help file:

1
~/jelastic/help

CLI help

Here, you can see the hierarchical list of the available command types (methods). Each method has the dedicated same-named folder with several scripts (i.e. available functions) inside.

4. In order to get the list of all possible operations for a particular method, you can use a simple listing command for the appropriate directory, for example:

1
ls ~/jelastic/environment/control

CLI environment control list

Each of the presented functions can be easily called using the full path to it.

5. For more information on a particular operation, run it without parameters to see the complete list of missed requirements.

CLI command help

You can also check our API documentation for getting additional information.

6. By default, the “loading” animation is displayed while waiting for any command execution. It provides a visual representation of the action in progress.

However, if you need to save the response into a file (e.g. to use it in some automation tasks), this element may be redundant and corrupt JSON formatting. To hide the loading animation, append your command with the following argument:

1
--silent true

In such a way, the received output can be immediately used by your automation scripts without any additional edits.

Tip: The installed CLI automatically checks for updates. When a new version becomes available, you’ll see the corresponding notification with the upgrade instructions.

Now, as you have some basic knowledge of Jelastic CLI, you can continue exploring it on your own.

CLI Tutorials

Ensuring the full-functional remote management, Jelastic CLI works with all types of environments and applications. It supports all of the appropriate actions, from the simplest to the complex ones. To reveal its capabilities with real showcases, we present some of the most common examples of its usage:

Subsequently, when you catch the idea of how to work with Jelastic CLI and the possibilities it provides, you can start creating your own automation scripts for some frequent environment lifecycle operations.

You can find complete information on all of the available commands and methods within the Jelastic API documentation.

What’s next?