Back to Abp

Custom Commands

docs/en/studio/custom-commands.md

10.3.05.3 KB
Original Source
json
//[doc-seo]
{
    "Description": "Learn how to create and manage custom commands in ABP Studio to automate build, deployment, and other workflows."
}

Custom Commands

json
//[doc-nav]
{
  "Next": {
    "Name": "Working with ABP Suite",
    "Path": "studio/working-with-suite"
  }
}

Custom commands allow you to define reusable terminal commands that appear in context menus throughout ABP Studio. You can use them to automate repetitive tasks such as building Docker images, installing Helm charts, running deployment scripts, or executing any custom workflow.

Note: This is an advanced feature primarily intended for teams working with Kubernetes deployments or complex build/deployment workflows. If you're developing a standard application without custom DevOps requirements, you may not need this feature.

Opening the Management Window

To manage custom commands, right-click on the solution root in Solution Explorer and select Manage Custom Commands.

The management window displays all defined commands with options to add, edit, or delete them.

Creating a New Command

Click the Add New Command button to open the command editor dialog.

Command Properties

PropertyDescription
Command NameA unique identifier for the command (used internally)
Display NameThe text shown in context menus
Terminal CommandThe PowerShell command to execute. Use &&& to chain multiple commands
Working DirectoryOptional. The directory where the command runs (relative to solution path)
ConditionOptional. A Scriban expression that determines when the command is visible
Require ConfirmationWhen enabled, shows a confirmation dialog before execution
Confirmation TextThe message shown in the confirmation dialog

Trigger Targets

Trigger targets determine where your command appears in context menus. You can select multiple targets for a single command.

TargetLocation
Helm Charts RootKubernetes panel > Helm tab > root node
Helm Main ChartKubernetes panel > Helm tab > main chart
Helm Sub ChartKubernetes panel > Helm tab > sub chart
Kubernetes ServiceKubernetes panel > Kubernetes tab > service
Solution Runner RootSolution Runner panel > profile root
Solution Runner FolderSolution Runner panel > folder
Solution Runner ApplicationSolution Runner panel > application

Execution Targets

Execution targets define where the command actually runs. This enables cascading execution:

  • When you trigger a command from a root or parent item, it can recursively execute on all matching children
  • For example: trigger from Helm Charts Root with execution target Helm Sub Chart → the command runs on each sub chart

Template Variables

Commands support Scriban template syntax for dynamic values. Use {%{{{variable}}}%} to insert context-specific data.

Available Variables by Context

Helm Charts:

VariableDescription
profile.nameKubernetes profile name
profile.namespaceKubernetes namespace
chart.nameCurrent chart name
chart.pathChart directory path
metadata.*Hierarchical metadata values (e.g., metadata.imageName)
secrets.*Secret values (e.g., secrets.registryPassword)

Kubernetes Service:

VariableDescription
nameService name
profile.nameKubernetes profile name
profile.namespaceKubernetes namespace
mainChart.nameParent main chart name
chart.nameRelated sub chart name
chart.metadata.*Chart-specific metadata

Solution Runner (Root, Folder, Application):

VariableDescription
profile.nameRun profile name
profile.pathProfile file path
application.nameApplication name (Application context only)
application.baseUrlApplication URL (Application context only)
folder.nameFolder name (Folder/Application context)
metadata.*Profile metadata values
secrets.*Profile secret values

Example: Build Docker Image

Here's an example command that builds a Docker image for Helm charts:

Command Properties:

  • Command Name: buildDockerImage
  • Display Name: Build Docker Image
  • Terminal Command: ./build-image.ps1 -ProjectPath {%{{{metadata.projectPath}}}%} -ImageName {%{{{metadata.imageName}}}%}
  • Working Directory: etc/helm
  • Trigger Targets: Helm Charts Root, Helm Main Chart, Helm Sub Chart
  • Execution Targets: Helm Main Chart, Helm Sub Chart
  • Condition: {%{{{metadata.projectPath}}}%}

This command:

  1. Appears in the context menu of Helm charts root and all chart nodes
  2. Executes on main charts and sub charts (cascading from root if triggered there)
  3. Only shows for charts that have projectPath metadata defined
  4. Runs the build-image.ps1 script with dynamic parameters from metadata