CLI

The Deviceplane CLI can be used to manage the releases in applications, SSH into devices in a project and used to help manage your projects and applications. Besides personal preference of using a CLI versus UI, another great use case of the CLI is to use it in an existing CI/CD system to deploy new releases directly into Deviceplane.

The CLI can be downloaded for the OS that is being used under the user dropdown located in the upper right hand corner of the UI.

Access Key

When using the CLI, an access key must be provided. Without this access key, Deviceplane will not be able to authenticate the request. Each user or service account can create access keys to use for the CLI. User access keys are scoped to a specific user and will have the same role as a user. Service account access keys are great to use when a service is being set up to make changes into Deviceplane. For example, it's best to use a service account access key instead of a user access key for CI/CD systems.

The access key can be set as an environment variable $DEVICEPLANE_ACCESS_KEY or as an option, --access-key value in any command.

Setting the access key as an environment variable is recommended so that it doesn't need to be constantly passed with every command. Even if the access key has been set as an environment variable, it can always be overridden by setting it directly in the command.

Deploying Releases

The most common use case of using the CLI is to deploy a new release for your application. Deploying a new release is simply passing in a yaml file that specifies the config of the release. The project and application needs to be specified in order to create a new release. The project and application can be set as environment variables or passed in as options in the command to determine which project and application the new release will apply to.

Option 1: Using Environment variables

If a single application is constantly being updated, Deviceplane recommends setting up environment variables so the project and application do not have to be passed in as same options in the command.

Environment VariableValueDescription
$DEVICEPLANE_ACCESS_KEYUser or Service Account Access KeyAccess Key to access the project/application
$DEVICEPLANE_PROJECTProject ID or NameDefine which project your application is in
$DEVICEPLANE_APPLICATIONApplication ID or NameDefine which application you want to deploy a new release to
# Set environment variables for access key, project and application
$ printenv
DEVICEPLANE_ACCESS_KEY=<ACCESS_KEY>
DEVICEPLANE_PROJECT=<PROJECT_ID_OR_NAME>
DEVICEPLANE_APPLICATION=<APPLICATION_ID_OR_NAME>
$ deviceplane deploy <CONFIG_YML>

Option 2: Passing in options in the command

If you don't want to set environment variables, the project and application can always be passed as the options for each command. Whenever these options are passed in a command, it overrides any environment variables so that the option passed in is used.

# Set only the access key as an environment variable
$ printenv
DEVICEPLANE_ACCESS_KEY=<ACCESS_KEY>
# Deploy by specifying the project and application in the command
$ deviceplane deploy --project <PROJECT_ID_OR_NAME> --application
<APPLICATION_ID_OR_NAME> <CONFIG_YML>

Environment Interpolation

When creating the yaml file for the release, your configuration options can contain environment variables so that the file will be use the variable values from the shell environment running the deviceplane deploy command. Environment interpolation is only supported in the CLI and not supported in config file the UI.

During deployment, if there are missing environment variables, the CLI will error out and list which variables are missing.

Only $VALUE and ${VALUE} syntax are supported. Other typical shell syntax options are not supported. If your configuration needs a dollar sign, you must use a $$ so that it is not attempted to be interpolated.

service1:
image: '$IMAGE_NAME_AND_TAG'
command: '${COMMAND}'

Putting $$ in front of any word prevents any interpolation to occur.

service1:
image: '$IMAGE_NAME_AND_TAG'
command: '${COMMAND}'
labels:
key: '$${NOT_INTERPOLATED}'

Editing Existing Releases

An easy way to update an existing release is to edit it using the CLI. Similar to deploying releases, the project and application can be set as environment variables or as options in the command.

When running deviceplane edit, the CLI pulls up the current config of the application into an editor. After the config is saved and exited, it is automatically deployed into the application.

# Environment variables are set for access key, project and application
$ printenv
DEVICEPLANE_ACCESS_KEY=<ACCESS_KEY>
DEVICEPLANE_PROJECT=<PROJECT_ID_OR_NAME>
DEVICEPLANE_APPLICATION=<APPLICATION_ID_OR_NAME>
$ deviceplane edit