> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-harness-cli/cli-for-continuous-delivery.md).

# CLI for Continuous Delivery

Use the [Harness CLI](https://github.com/harness/cli) to manage Continuous Delivery resources including services, environments, infrastructure definitions, and service overrides. Go to [Harness CLI](/harness-ai/use-harness-cli/harness-cli.md) to install, authenticate, and review all supported resources.

All commands follow the `harness [verb] [noun] <identifier>` pattern. Every `list` command supports `--ui` for interactive browsing, `--all` to fetch every page, and `--format table|json|jsonl|csv|tsv|markdown` for output control.

{% hint style="info" %}
**PIPELINE COMMANDS**

Go to [Continuous Delivery and pipeline commands](/harness-ai/use-harness-cli/harness-cli/harness-cli-commands/cd-and-pipeline-commands.md) to manage pipelines, executions, triggers, input sets, templates, and freeze windows from the CLI.
{% endhint %}

***

### What will you learn in this topic? <a href="#what-will-you-learn-in-this-topic" id="what-will-you-learn-in-this-topic"></a>

By the end of this page, you will know how to:

* Create, inspect, update, and delete service definitions from the CLI.
* Manage environment entities and the `type` field that distinguishes production from pre-production targets.
* Work with infrastructure definitions and why `--env` is required for list, get, and delete.
* Use the two service override types (`ENV_GLOBAL_OVERRIDE` and `ENV_SERVICE_OVERRIDE`).
* Use the `--ui` flag for interactive browsing of Continuous Delivery resources.

***

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* **Continuous Delivery concepts:** Familiarity with services, environments, and infrastructure definitions. Go to [Continuous Delivery overview](/continuous-delivery/new-to-continuous-delivery/overview.md) to review the resource model.
* **Harness CLI installed and authenticated:** Go to [Install and upgrade](/harness-ai/use-harness-cli/harness-cli/install-and-upgrade.md) and [Authenticate](/harness-ai/use-harness-cli/harness-cli/authenticate.md) to set up the CLI.
* **Org and project scope configured:** All Continuous Delivery resources are project-scoped. Set a default org and project with `harness auth setscope` or pass `--org` and `--project` on each command.

***

### Services <a href="#services" id="services"></a>

A service represents what you deploy: the artifact, the manifest, and any configuration that defines your application. Services are reusable across environments and stay consistent regardless of the deployment target.

#### List services <a href="#list-services" id="list-services"></a>

```sh
harness list service
harness list service --all --format json
harness list service --ui
```

<figure><img src="/files/PZIJZfPjG9ddlZqBWWAz" alt="Output of harness list service showing identifier, name, description, and updated columns"><figcaption><p>Click to view full size image</p></figcaption></figure>

#### Get a service <a href="#get-a-service" id="get-a-service"></a>

```sh
harness get service <service_id>
harness get service <service_id> --yaml > service.yaml
```

#### Create a service <a href="#create-a-service" id="create-a-service"></a>

Provide a YAML file with the service definition:

```sh
harness create service <service_id> -f service.yaml
```

#### Update a service <a href="#update-a-service" id="update-a-service"></a>

Fetch the YAML, edit locally, and push it back:

```sh
harness get service <service_id> --yaml > service.yaml
$EDITOR service.yaml
harness update service <service_id> -f service.yaml
```

#### Delete a service <a href="#delete-a-service" id="delete-a-service"></a>

```sh
harness delete service <service_id>
```

***

### Environments <a href="#environments" id="environments"></a>

An environment represents where you deploy: production, staging, QA, or any other target. The `type` field accepts `Production` or `PreProduction`. Environments hold environment-specific configuration such as variables, manifests, and overrides.

#### List environments <a href="#list-environments" id="list-environments"></a>

```sh
harness list environment
harness list environment --all --format json
harness list environment --ui
```

<figure><img src="/files/2lERNlsyflpQzbhV2D0E" alt="Output of harness get service and harness list environment showing environment identifier, name, type, and updated columns"><figcaption><p>Click to view full size image</p></figcaption></figure>

#### Get an environment <a href="#get-an-environment" id="get-an-environment"></a>

```sh
harness get environment <environment_id>
harness get environment <environment_id> --yaml > environment.yaml
```

<figure><img src="/files/tLSctzPBcnrazU8zdjRy" alt="Output of harness get environment and harness list infrastructure showing infrastructure identifier, name, type, deploy type, and updated columns"><figcaption><p>Click to view full size image</p></figcaption></figure>

#### Create an environment <a href="#create-an-environment" id="create-an-environment"></a>

Provide a YAML file with the environment definition:

```sh
harness create environment <environment_id> -f environment.yaml
```

#### Update an environment <a href="#update-an-environment" id="update-an-environment"></a>

Fetch the YAML, edit locally, and push it back:

```sh
harness get environment <environment_id> --yaml > environment.yaml
$EDITOR environment.yaml
harness update environment <environment_id> -f environment.yaml
```

#### Delete an environment <a href="#delete-an-environment" id="delete-an-environment"></a>

```sh
harness delete environment <environment_id>
```

***

### Infrastructure definitions <a href="#infrastructure-definitions" id="infrastructure-definitions"></a>

An infrastructure definition describes the compute target where a service is deployed within an environment. It specifies the cluster, namespace, region, or other details Harness needs to execute the deployment. Infrastructure definitions always belong to an environment, so `--env <environment_id>` is required for `list`, `get`, and `delete`.

#### List infrastructure definitions <a href="#list-infrastructure-definitions" id="list-infrastructure-definitions"></a>

```sh
harness list infrastructure --env <environment_id>
harness list infrastructure --env <environment_id> --format json
harness list infrastructure --env <environment_id> --ui
```

#### Get an infrastructure definition <a href="#get-an-infrastructure-definition" id="get-an-infrastructure-definition"></a>

```sh
harness get infrastructure <infrastructure_id> --env <environment_id>
harness get infrastructure <infrastructure_id> --env <environment_id> --yaml > infra.yaml
```

<figure><img src="/files/sXgJt9X5EH3Qd0zEYiRV" alt="Output of harness get infrastructure showing identifier, name, type, environment, deploy type, updated, and created fields"><figcaption><p>Click to view full size image</p></figcaption></figure>

#### Create an infrastructure definition <a href="#create-an-infrastructure-definition" id="create-an-infrastructure-definition"></a>

Provide a YAML file with the infrastructure definition:

```sh
harness create infrastructure <infrastructure_id> -f infra.yaml
```

#### Update an infrastructure definition <a href="#update-an-infrastructure-definition" id="update-an-infrastructure-definition"></a>

Fetch the YAML, edit locally, and push it back:

```sh
harness get infrastructure <infrastructure_id> --env <environment_id> --yaml > infra.yaml
$EDITOR infra.yaml
harness update infrastructure <infrastructure_id> -f infra.yaml
```

#### Delete an infrastructure definition <a href="#delete-an-infrastructure-definition" id="delete-an-infrastructure-definition"></a>

```sh
harness delete infrastructure <infrastructure_id> --env <environment_id>
```

***

### Service overrides <a href="#service-overrides" id="service-overrides"></a>

Service overrides customize service configuration for a specific environment without modifying the base service definition. Use them to override manifests, variables, or config files so the same service stays portable across environments.

The `type` field accepts two values:

* `ENV_GLOBAL_OVERRIDE`: applies to all services in the environment.
* `ENV_SERVICE_OVERRIDE`: applies to one specific service in the environment.

#### List service overrides <a href="#list-service-overrides" id="list-service-overrides"></a>

```sh
harness list service_override --env <environment_id>
harness list service_override --env <environment_id> --format json
harness list service_override --env <environment_id> --ui
```

#### Get a service override <a href="#get-a-service-override" id="get-a-service-override"></a>

```sh
harness get service_override <override_id>
harness get service_override <override_id> --yaml > override.yaml
```

#### Create a service override <a href="#create-a-service-override" id="create-a-service-override"></a>

Provide a YAML file with the override definition:

```sh
harness create service_override <override_id> -f override.yaml
```

#### Update a service override <a href="#update-a-service-override" id="update-a-service-override"></a>

Fetch the YAML, edit locally, and push it back:

```sh
harness get service_override <override_id> --yaml > override.yaml
$EDITOR override.yaml
harness update service_override <override_id> -f override.yaml
```

#### Delete a service override <a href="#delete-a-service-override" id="delete-a-service-override"></a>

```sh
harness delete service_override <override_id>
```

***

### Interactive TUI <a href="#interactive-tui" id="interactive-tui"></a>

All `list` commands support `--ui` for a paged, interactive browser. The TUI requires a TTY on both stdin and stdout. Do not pass `--ui` in CI or headless environments.

When you drill into an execution from the TUI, you can navigate between the **Logs**, **Details**, **Inputs**, and **Outputs** tabs using the keyboard shortcuts shown in the footer.

The **Logs** tab streams step output in real time:

<figure><img src="/files/T7KM06Dx5see7WGXm1VB" alt="TUI execution logs tab showing Initialize step with machine provisioning output"><figcaption><p>Click to view full size image</p></figcaption></figure>

The **Details** tab shows execution metadata including FQN, status, start and end times, duration, and the assigned delegate:

<figure><img src="/files/IGpujgwywuwTNta31ky0" alt="TUI execution details tab showing FQN, status, duration, timeout, and delegate name"><figcaption><p>Click to view full size image</p></figcaption></figure>

The **Inputs** tab shows the step configuration as JSON:

<figure><img src="/files/tDGpfOQXz7M5hNgdKP9P" alt="TUI execution inputs tab showing step configuration JSON including identifier, name, timeout, type, and spec"><figcaption><p>Click to view full size image</p></figcaption></figure>

{% hint style="info" %}
**TTY REQUIREMENT**

The `--ui` flag is mutually exclusive with `--format`, `--out`, and stream redirection. For non-interactive contexts, use `--format json` or `--format jsonl` instead.
{% endhint %}

***

### Next steps <a href="#next-steps" id="next-steps"></a>

* Go to [Continuous Delivery and pipeline commands](/harness-ai/use-harness-cli/harness-cli/harness-cli-commands/cd-and-pipeline-commands.md) to manage pipelines, executions, triggers, input sets, and freeze windows from the CLI.
* Go to [Harness CLI overview](/harness-ai/use-harness-cli/harness-cli/harness-cli-overview.md) to install, authenticate, and configure the Harness CLI.
* Go to [Continuous Delivery integrations](/continuous-delivery/new-to-continuous-delivery/cd-integrations.md) to review which platforms and tools Harness Continuous Delivery supports.
* Go to the [Harness CLI GitHub repository](https://github.com/harness/cli) to view source code and releases.
* Go to the [Harness CLI command reference](https://github.com/harness/cli/wiki/Command-Reference) to explore the full list of available commands.
