Skip to main content
Version: 2.0 🆕

Tron CLI

Tron is a command-line tool that automates Devtron application and configuration tasks using modular YAML configuration files.

Support status The CLI is currently validated and supported for the Enterprise edition. Other editions may work but are not officially supported yet.

Highlights​

  • Create Devtron applications from YAML
  • Update existing applications
  • Manage environments and pipelines
  • Simple CLI interface
  • Usable as a Python module

Install​

pip install devtron-cli

Quick Start​

# Create a new application (provide Devtron URL and API token via CLI or environment variables)
tron --config config.yaml create-app --devtron-url https://devtron.example.com --api-token your-api-token

# Update an existing application
tron --config config.yaml update-app --devtron-url https://devtron.example.com --api-token your-api-token

# Or set environment variables and omit the URL and token from CLI
export DEVTRON_URL=https://devtron.example.com
export DEVTRON_API_TOKEN=your-api-token
tron --config config.yaml create-app

Global Options​

These options can be used with any command:

OptionShortRequiredDescriptionPossible Values
--config-cNoPath to the YAML configuration fileAny valid file path
--devtron-url-uYesDevtron URLValid Devtron instance URL
--api-token-tYesAPI tokenValid Devtron API token with required access

Environment Variables​

You can also set the following environment variables instead of providing options on the command line:

Environment VariableDescription
DEVTRON_URLDevtron URL
DEVTRON_API_TOKENDevtron API token

Commands​

1. create-app​

Creates a new application in Devtron.

tron create-app [OPTIONS]

Options​

OptionShortRequiredDescriptionPossible Values
--config-cYesPath to the YAML configuration fileAny valid file path
--devtron-url-uYesDevtron URLValid Devtron instance URL
--api-token-tYesAPI tokenValid Devtron API token with required access

Configuration File Fields​

The configuration file should contain the following fields:

FieldRequiredDescriptionPossible Values
app_nameYesName of the applicationString
project_nameYesName of the projectString
descriptionNoDescription of the applicationString
labelsNoLabels for the applicationArray of label objects
git_repositoriesYesGit repository configurationsArray of git repository objects
build_configurationsYesBuild configuration settingsBuild configuration object
config_approvalNoConfiguration approval settings (if enabled)Object
base_configurationsYesBase deployment configurationBase configuration object
workflowsYesWorkflow configurations for CI/CDArray of workflow objects

Label Object Structure​

FieldRequiredDescriptionPossible Values
keyYesLabel keyString
valueYesLabel valueString
propagateNoWhether to propagate the label to all resources created in applicationtrue or false

Git Repository Object Structure​

FieldRequiredDescriptionPossible Values
urlYesGit repository URLValid Git URL
git_account_nameYesName of the git accountString
checkout_pathYesPath to checkout the repositoryString (default: "./")
fetch_submodulesNoWhether to fetch submodulestrue or false
filter_patternNoFilter patterns for filesArray of strings

Build Configuration Object Structure​

FieldRequiredDescriptionPossible Values
container_registry_nameYesName of the container registryString
repository_nameYesName of the repositoryString
target_platformNoTarget platforms for buildxComma-separated platform list
dockerfile_repositoryYesRepository for DockerfileString
build_contextNoDocker build contextString (default: "./")
docker_build_argsNoDocker build argumentsKey-value pairs
build_typeYesType of build"DockerfileExists", "CreateDockerfile", or "Buildpacks"
dockerfile_pathYes (if build_type is DockerfileExists)Path to DockerfileString
languageYes (if build_type is CreateDockerfile)Programming languageString
language_frameworkYes (if build_type is CreateDockerfile)FrameworkString
dockerfile_contentYes (if build_type is CreateDockerfile)Dockerfile contentMulti-line string
builder_imageYes (if build_type is Buildpacks)Builder image for buildpacksString
versionYes (if build_type is Buildpacks)Language versionString

Base Configuration Object Structure​

FieldRequiredDescriptionPossible Values
deployment_templateYesBase deployment templateTemplate object
config_mapsNoConfigMap configurationsArray of ConfigMap objects
secretsNoSecret configurationsArray of Secret objects

Template Object Structure​

FieldRequiredDescriptionPossible Values
versionYesVersion of the template"1.6.0", "4.21.0", "5.0.0"
chart_typeYesType of chart"Job & CronJob", "Deployment", "StatefulSet", "GPU-Workload", "Rollout Deployment"
use_defaultNoWhether to use default valuestrue or false
values_patchNo (works only if use_default is true)Patch/override keys in deployment templateObject

ConfigMap Object Structure​

FieldRequiredDescriptionPossible Values
nameYesName of the ConfigMapString
typeNoType of ConfigMap"volume" or "environment" (default: "environment")
dataYes (if from_file not provided)Key-value dataObject
mountPathNoMount path for volumeString
subPathNoWhether to use subPathtrue or false
filePermissionNoFile permissionString
externalNoWhether it's an external ConfigMaptrue or false
from_fileYes (if data not provided)Path to ConfigMap value fileString

Secret Object Structure​

FieldRequiredDescriptionPossible Values
nameYesName of the SecretString
typeNoType of Secret"volume" or "environment" (default: "environment")
dataNoKey-value dataObject
mountPathNoMount path for volumeString
subPathNoWhether to use subPathtrue or false
filePermissionNoFile permissionString
externalNoWhether it's an external Secrettrue or false
from_fileNoPath to Secret value fileString
roleARNNoAWS role ARNString
externalTypeNoExternal secret typeString (for example, "ESO_AWSSecretsManager")
esoSecretDataNoESO secret dataObject

Workflow Object Structure​

FieldRequiredDescriptionPossible Values
ci_pipelineYesCI pipeline configurationCI Pipeline object
cd_pipelinesNoCD pipeline configurationsArray of CD Pipeline objects

CI Pipeline Object Structure​

FieldRequiredDescriptionPossible Values
typeYesType of pipeline"CI_JOB", "CI_BUILD", "LINKED"
is_manualYesWhether to trigger the CI pipeline manuallytrue or false
nameYesName of the CI pipelineString
branchesYes (unless type is LINKED)Branches for the git repositoriesArray of branch objects
source_pipelineYes (if type is LINKED)Name of the source CI pipelineString
pre_build_configsNoPre-build configurationsObject (see below)
post_build_configsNoPost-build configurationsObject (see below)
Pre/Post Build Configs Object Structure​
FieldRequiredDescriptionPossible Values
tasksNoList of build tasksArray of build task objects
is_manualNoManual triggertrue or false (default: true)
Build Task Object Structure​
FieldRequiredDescriptionPossible Values
typeYesType of build task"plugin" or "custom"
task_nameYesName of the taskString
nameNoName of the pluginString
versionNoPlugin versionString
descriptionNoTask descriptionString
input_variablesNoInput variablesKey-value dict or array (custom tasks)
output_variablesNoOutput variables (custom tasks)Array of variable objects
output_directory_pathsNoOutput directories (custom tasks)Array of strings
scriptNoScript to execute (custom tasks)Multi-line string
container_imageNoContainer image for taskString
script_mount_pathNoScript mount pathString
commandNoCommand to runString
argsNoCommand argumentsArray of strings
ports_mappingsNoPort mappingsArray of mappings
script_mount_path_on_containerNoScript path inside containerString
directory_mappingsNoDirectory mappingsArray of mappings
trigger_conditionsNoTrigger conditionsArray of condition objects
pass_conditionsNoPass conditionsArray of condition objects

Branch Object Structure​

FieldRequiredDescriptionPossible Values
repoYesRepository nameString
branchYesBranch nameString
typeYesBranch type"SOURCE_TYPE_BRANCH_FIXED"
regexNoRegex pattern for branchString

Build Config Object Structure​

FieldRequiredDescriptionPossible Values
typeYesType of pre or post build config"plugin" or "custom"
nameNoName of the plugin to useString
versionNoVersion of the plugin to useString
descriptionNoTask descriptionString
input_variablesNoInput variablesArray of variable objects

Variable Object Structure​

FieldRequiredDescriptionPossible Values
Variable nameYesVariable nameString
Variable valueYesVariable valueString

CD Pipeline Object Structure​

FieldRequiredDescriptionPossible Values
nameNoName of the CD pipelineString
environment_nameYesName of the environment for deploymentString
is_manualYesWhether to trigger the CD pipeline manuallytrue or false
deployment_typeNoDeployment type"helm", "argo_cd" (default: "helm")
placementNoPlacement strategy"parallel", "serial" (default: "parallel")
deployment_strategiesNoDeployment strategiesArray of strategy objects
depends_onNoName of environment to which this pipeline needs to be attachedString
pre_cd_configsNoPre-deploy configurationsObject (see below)
post_cd_configsNoPost-deploy configurationsObject (see below)
env_configurationNoEnvironment-specific overridesObject (see below)
Pre/Post CD Configs Object Structure​
FieldRequiredDescriptionPossible Values
tasksNoList of build tasksArray of build task objects
is_manualNoManual triggertrue or false (default: true)
run_in_app_envNoRun tasks in app environmenttrue or false
Env Configuration Object Structure​
FieldRequiredDescriptionPossible Values
deployment_templateNoDeployment template overrideObject
config_mapsNoConfigMap overridesArray of ConfigMap objects
secretsNoSecret overridesArray of Secret objects

2. update-app​

Updates an existing application in Devtron.

tron update-app [OPTIONS]

Options​

OptionShortRequiredDescriptionPossible Values
--config-cYesPath to the YAML configuration fileAny valid file path
--devtron-url-uYesDevtron URLValid Devtron instance URL
--api-token-tYesAPI tokenValid Devtron API token

Configuration File Fields​

The configuration file structure is the same as for create-app. Refer to the create-app section for details on all possible fields and their values.

3. get-app​

Gets application configuration from Devtron and outputs it in YAML format.

tron get-app --app APPLICATION_NAME [OPTIONS]

Options​

OptionShortRequiredDescriptionPossible Values
--appYesName of the application to fetchString
--config-cNoPath to the YAML configuration fileAny valid file path
--devtron-url-uYesDevtron URLValid Devtron instance URL
--api-token-tYesAPI tokenValid Devtron API token

Examples​

Create a new application​

tron create-app -c config.yaml -u https://devtron.example.com -t your_api_token

Update an existing application​

tron update-app -c config.yaml -u https://devtron.example.com -t your_api_token

Get application configuration​

tron get-app --app my-app -u https://devtron.example.com -t your_api_token

Sample Configuration File (create-app)​

app_name: "my-application"
project_name: "my-project"
description: "Sample application created via Tron"
labels:
- key: "app-usage"
value: "platform"
propagate: false
- key: "owner"
value: "devtron-team"
propagate: true
git_repositories:
- url: "https://github.com/org/sample-repo.git"
git_account_name: "GitHub"
checkout_path: "./src"
fetch_submodules: false
filter_pattern:
- "!Dockerfile.old"
- url: "https://github.com/org/another-repo.git"
git_account_name: "GitHub"
checkout_path: "./lib"
build_configurations:
container_registry_name: "company-registry"
repository_name: "sample-app"
target_platform: "linux/amd64,linux/arm64"
dockerfile_repository: "sample-repo"
build_context_repository: "sample-repo"
build_context: "./"
docker_build_args:
ENV: production
DEBUG: "false"
build_type: "DockerfileExists"
dockerfile_path: "Dockerfile"
config_approval:
action: proposed
if_draft_already_exists: merge
notify_all: true
specific_approvers:
- "devtron@example.com"
comments: "Proposed by CLI"
base_configurations:
deployment_template:
show_application_metrics: true
version: "4.21.0"
chart_type: "Deployment"
# values_path: "base-deployment.yaml"
values_patch:
EnvVariables:
- name: ENVIRONMENT
value: production
replicaCount: 3
# NOTE: Set either values_path or values_patch (not both).
config_maps:
- name: app-config-env
data:
API_URL: "https://api.example.com"
FEATURE_FLAG: "enabled"
mountPath: /etc/config
subPath: true
filePermission: "0644"
- name: logging-config
data:
LOG_LEVEL: "INFO"
LOG_FORMAT: "json"
mountPath: /etc/logging
subPath: true
filePermission: "0644"
- name: external-config-env
external: true
- name: external-config-volume
external: true
mountPath: /mnt/external
subPath: true
filePermission: "0644"
- name: configmap-from-file-volume
from_file: "config-volume.yaml"
mountPath: /mnt/volume
subPath: true
filePermission: "0644"
- name: configmap-from-file-env
from_file: "config-env.yaml"
secrets:
- name: db-credentials
from_file: "db-creds.yaml"
mountPath: /etc/secrets
subPath: false
filePermission: "0600"
- name: api-secret
data:
API_KEY: "REDACTED"
API_SECRET: "REDACTED"
- name: external-secret-env
external: true
- name: external-secret-vol
external: true
mountPath: /mnt/secret
subPath: true
filePermission: "0600"
- name: cloud-secret
roleARN: "arn:aws:iam::123456789012:role/CloudSecretRole"
externalType: ESO_AWSSecretsManager
external: true
esoSecretData:
secretStore:
aws:
service: SecretsManager
region: us-east-1
auth:
secretRef:
accessKeyIDSecretRef:
name: aws-secret
key: access-key
secretAccessKeySecretRef:
name: aws-secret
key: secret-access-key
esoData:
- secretKey: prod-db-password
key: secrets/prod-db-secrets
property: prodPassword
esoSecretData:
secretStore:
aws:
service: SecretsManager
region: us-east-1
auth:
secretRef:
accessKeyIDSecretRef:
name: awssm-secret
key: access-key
secretAccessKeySecretRef:
name: awssm-secret
key: secret-access-key
esoData:
- secretKey: prod-mysql-password
key: secrets/prod-mysql-secrets
property: prodPassword
workflows:
- ci_pipeline:
type: "CI_JOB"
is_manual: true
name: "test-ci-pipeline"
branches:
- repo: "test"
branch: "master"
type: "SOURCE_TYPE_BRANCH_FIXED"
regex: ""
- repo: "getting-started-node-js"
branch: "main"
type: "SOURCE_TYPE_BRANCH_FIXED"
regex: ""
pre_build_configs:
tasks:
- type: "plugin"
task_name: Devtron CI Trigger
name: "Devtron CI Trigger"
version: "1.1.0"
input_variables:
DevtronApiToken: "demo-repo"
DevtronEndpoint: "https://demo.ai"
DevtronApp: "sample-app-10"
DevtronEnv: "@{{Keka}}"
- type: "custom"
task_name: "Create Readme File"
description: "Creates a README.md file with project information"
input_variables:
- key: "PROJECT_NAME"
type: "STRING"
value: "sample-app"
- key: "AUTHOR"
type: "STRING"
value: "devtron-labs"
output_variables:
- key: "README_PATH"
type: "STRING"
description: "Path to the created README file"
output_directory_paths:
- "/workspace"
script: |
#!/bin/sh
set -e
echo "# $PROJECT_NAME" > /workspace/README.md
echo "Author: $AUTHOR" >> /workspace/README.md
trigger_conditions:
- key: "PROJECT_NAME"
operator: "!="
value: "dummy-project"
pass_conditions:
- key: "README_PATH"
operator: "!="
value: "/workspace/README.md"
post_build_configs: {}
cd_pipelines:
- name: my-new-pipeline
environment_name: "devtron-demo"
is_manual: true
deployment_type: "helm"
placement: parallel
deployment_strategies:
- name: "Rolling"
strategy:
maxSurge: 25%
maxUnavailable: 1
default: true
- name: "recreate"
strategy: {}
pre_cd_configs:
tasks:
- type: "plugin"
task_name: Devtron CI Trigger
name: "Devtron CI Trigger"
version: "1.1.0"
input_variables:
DevtronApiToken: "demo-repo"
DevtronEndpoint: "https://demo.ai"
DevtronApp: "sample-app-10"
DevtronEnv: "@{{Keka}}"
- type: "custom"
task_name: "Run container task"
description: "Runs a container task with the specified image and command"
container_image: "alpine:latest"
input_variables:
- key: "PROJECT_NAME"
type: "STRING"
value: "sample-app"
- key: "AUTHOR"
type: "STRING"
value: "devtron-labs"
output_directory_paths:
- "/container_workspace"
script: |
#!/bin/sh
set -e
echo "# $PROJECT_NAME" > /container_workspace/README.md
echo "Author: $AUTHOR" >> /container_workspace/README.md
script_mount_path: "/container_workspace/test.sh"
command: "/bin/sh"
args: ["-c", "test.sh"]
ports_mappings:
- 8080:8090
script_mount_path_on_container: "/sourcecode/test.sh"
directory_mappings:
- "/devtroncd:/sourcecode"
- type: "plugin"
task_name: Code Scan
name: "Code Scan"
version: "1.0.0"
input_variables: {}
is_manual: true
run_in_app_env: true
post_cd_configs:
is_manual: true
tasks:
- type: "plugin"
task_name: Code Scan
name: "Code Scan"
version: "1.0.0"
input_variables: {}
- type: "plugin"
task_name: Devtron CI Trigger
name: "Devtron CI Trigger"
version: "1.1.0"
input_variables:
DevtronApiToken: "demo-repo-5"
DevtronEndpoint: "https://demo.ai"
DevtronApp: "sample-app-10"
DevtronEnv: "@{{Keka}}"
env_configuration:
deployment_template:
version: "4.20.0"
merge_strategy: "patch"
show_application_metrics: true
values_patch:
replicaCount: 2
resources:
limits:
cpu: "2"
memory: "500Mi"
requests:
cpu: "0.50"
memory: "200Mi"
config_maps:
- name: configmap-from-file-env
type: "volume"
mountPath: /etc/config
filePermission: "0400"
subPath: false
merge_strategy: "patch"
data:
key1: overridden-value1
key4: value4
- name: configmap-from-file-env-new
type: "volume"
mountPath: /etc/config
filePermission: "0400"
subPath: false
merge_strategy: "replace"
data:
key1: overridden-value1
key4: value4
secrets:
- name: secret-from-file-env
type: "volume"
mountPath: /etc/config
filePermission: "0400"
subPath: false
merge_strategy: "replace"
from_file: "test-config-map.yaml"
data:
key1: overridden-value1
key4: value4
- name: secret-from-file-env-new
data:
key1: overridden-value1
key4: value4
- name: demo3-deploy
environment_name: "demo3"
is_manual: true
deployment_type: "helm"
- ci_pipeline:
type: "LINKED"
is_manual: true
name: "test-ci-pipeline-2"
source_pipeline: "test-ci-pipeline"
cd_pipelines:
- name: demo2-deploy
environment_name: "demo2"
is_manual: true
deployment_type: "helm"
pre_cd_configs:
tasks:
- type: "plugin"
task_name: Devtron CI Trigger
name: "Devtron CI Trigger"
version: "1.1.0"
input_variables:
DevtronApiToken: "demo-repo"
DevtronEndpoint: "https://demo.ai"
DevtronApp: "sample-app-10"
DevtronEnv: "@{{Keka}}"
- type: "plugin"
task_name: Code Scan
name: "Code Scan"
version: "1.0.0"
input_variables: {}
is_manual: true