> ## Documentation Index
> Fetch the complete documentation index at: https://www.qovery.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# qovery lifecycle

> Lifecycle job management commands

## Overview

Manage lifecycle jobs within your Qovery environment. Lifecycle jobs run at specific points in your environment lifecycle (e.g., before/after deployment, on start, on stop, on delete).

## Commands

### List Lifecycle Jobs

List all lifecycle jobs in current environment:

```bash theme={null}
qovery lifecycle list
```

### Deploy Lifecycle Job

Deploy a lifecycle job:

```bash theme={null}
qovery lifecycle deploy --lifecycle "my-lifecycle"
```

Deploy multiple lifecycle jobs at once:

```bash theme={null}
qovery lifecycle deploy --lifecycles "lifecycle1,lifecycle2"
```

Deploy with a specific commit ID or image tag:

```bash theme={null}
qovery lifecycle deploy --lifecycle "my-lifecycle" --commit-id "abc123"
qovery lifecycle deploy --lifecycle "my-lifecycle" --tag "v1.2.0"
```

**Flags:**

| Flag             | Short | Description                                                |
| ---------------- | ----- | ---------------------------------------------------------- |
| `--lifecycle`    | `-n`  | Lifecycle Job Name                                         |
| `--lifecycles`   |       | Lifecycle Job Names (comma separated)                      |
| `--commit-id`    | `-c`  | Lifecycle Commit ID                                        |
| `--tag`          | `-t`  | Lifecycle Tag                                              |
| `--watch`        | `-w`  | Watch lifecycle status until it's ready or an error occurs |
| `--organization` |       | Organization Name                                          |
| `--project`      |       | Project Name                                               |
| `--environment`  |       | Environment Name                                           |

### Redeploy Lifecycle Job

Redeploy an existing lifecycle job with the same configuration:

```bash theme={null}
qovery lifecycle redeploy --lifecycle "my-lifecycle"
```

### Stop Lifecycle Job

Stop a lifecycle job:

```bash theme={null}
qovery lifecycle stop --lifecycle "my-lifecycle"
```

### Delete Lifecycle Job

Delete a lifecycle job:

```bash theme={null}
qovery lifecycle delete --lifecycle "my-lifecycle"
```

### Cancel Deployment

Cancel a lifecycle job deployment:

```bash theme={null}
qovery lifecycle cancel --lifecycle "my-lifecycle"
```

### Update Lifecycle Job

Update lifecycle job source configuration (branch, tag, or image name):

```bash theme={null}
# Update git branch (for Dockerfile-based lifecycle jobs)
qovery lifecycle update --lifecycle "my-lifecycle" --branch "main"

# Update image tag (for image-based lifecycle jobs)
qovery lifecycle update --lifecycle "my-lifecycle" --tag "v2.0.0"

# Update image name
qovery lifecycle update --lifecycle "my-lifecycle" --image-name "my-registry/my-image"
```

**Flags:**

| Flag             | Short | Description                                            |
| ---------------- | ----- | ------------------------------------------------------ |
| `--lifecycle`    | `-n`  | Lifecycle Name (required)                              |
| `--branch`       | `-b`  | Lifecycle Branch (for Dockerfile-based lifecycle jobs) |
| `--tag`          | `-t`  | Lifecycle Tag (for image-based lifecycle jobs)         |
| `--image-name`   |       | Lifecycle Image Name (for image-based lifecycle jobs)  |
| `--organization` |       | Organization Name                                      |
| `--project`      |       | Project Name                                           |
| `--environment`  |       | Environment Name                                       |

### Clone Lifecycle Job

Clone a lifecycle job to another environment or project:

```bash theme={null}
qovery lifecycle clone --lifecycle "my-lifecycle"
```

**Flags:**

| Flag                      | Short | Description               |
| ------------------------- | ----- | ------------------------- |
| `--lifecycle`             | `-n`  | Lifecycle Name (required) |
| `--target-project`        |       | Target Project Name       |
| `--target-environment`    |       | Target Environment Name   |
| `--target-lifecycle-name` |       | Target Lifecycle Name     |
| `--organization`          |       | Organization Name         |
| `--project`               |       | Project Name              |
| `--environment`           |       | Environment Name          |

## Examples

### Deploy Database Migration Job

```bash theme={null}
# List lifecycle jobs
qovery lifecycle list

# Deploy migration job
qovery lifecycle deploy --lifecycle "db-migration"

# Deploy and watch status
qovery lifecycle deploy --lifecycle "db-migration" --watch
```

### Update Lifecycle Job and Redeploy

```bash theme={null}
# Update branch for a git-based lifecycle job
qovery lifecycle update --lifecycle "db-migration" --branch "feature/new-migration"

# Redeploy to apply changes
qovery lifecycle redeploy --lifecycle "db-migration"
```

### Run Post-Deployment Script with Specific Tag

```bash theme={null}
qovery lifecycle deploy --lifecycle "post-deploy-script" --tag "v1.5.0"
```

## Lifecycle Job Types

| Event      | Description                      |
| ---------- | -------------------------------- |
| **START**  | Runs when environment starts     |
| **STOP**   | Runs when environment stops      |
| **DELETE** | Runs before environment deletion |
| **DEPLOY** | Runs during deployment           |

## Related Commands

* [`qovery cronjob`](/cli/commands/cronjob) - Manage scheduled cronjobs
* [`qovery log`](/cli/commands/log) - View lifecycle job logs
* [`qovery status`](/cli/commands/status) - Check lifecycle job status
