Overview
A Lifecycle Job is a Kubernetes job that is triggered by environment lifecycle events (deploy, stop, or delete). Unlike Cron Jobs that run on a schedule, Lifecycle Jobs execute when specific environment events occur. Key Features:- Triggered by environment events (deploy, stop, delete)
- Can output variables to other services in the environment
- Supports both Git and Container Registry sources
- Seed databases in preview environments
- Create external resources not managed by Qovery (S3 buckets, DNS records)
- Run database migrations
- Generate dynamic configuration or API keys
- Clean up resources on environment deletion
Deployment Sources
Qovery supports two deployment sources for Lifecycle Jobs:Git Repository
Qovery pulls your code from a Git repository, builds the application, and deploys it to your Kubernetes cluster. Supported Providers: GitHub, GitLab, BitbucketContainer Registry
Qovery pulls a pre-built container image from your configured registry and deploys it to your Kubernetes cluster.Creating a Lifecycle Job
Configure Source
For Git Repository:
- Select Git provider
- Choose repository
- Select branch
- Specify root path (if not at repository root)
- Configure Dockerfile path
- Select configured registry
- Enter image name
- Specify image tag
Configure Triggers
Select which lifecycle events should trigger this job:
- Deploy: Run when environment is deployed
- Stop: Run when environment is stopped
- Delete: Run when environment is deleted
- Custom entrypoint (optional)
- CMD arguments (optional)
- Restart policy
- Max duration
- Port (if needed for health checks)
Configuration
General Settings
Name: Unique identifier for your Lifecycle Job within the environment Source Configuration:- Git: Provider, repository, branch, root path, Dockerfile path, build arguments, target stage
- Registry: Image name and tag
Triggers
Configure which lifecycle events trigger this job: Deploy Event: Triggered when the environment is deployed. Use for:- Running database migrations
- Seeding initial data
- Creating cloud resources
- Generating API keys or configuration
- Creating backups
- Archiving data
- Notifying external systems
- Cleaning up external resources
- Deleting cloud resources
- Removing API keys or tokens
- Entrypoint: Override container entrypoint
- CMD Arguments: Provide command arguments
- Restart Policy: Configure failure handling
- Max Duration: Execution timeout (in seconds)
- Port: For health checks (optional)
Resources
- vCPU: CPU allocation in millicores (default: 500m)
- Memory: RAM allocation (default: 512MB)
Input Variables
Lifecycle Jobs have access to:- Built-in Qovery variables (environment ID, project ID, service connections)
- Custom environment variables
- Secrets
Job Output Variables
Lifecycle Jobs can output data that gets injected as environment variables into other services in your environment.Output File
Write your output to:Output Format
The output file must be valid JSON:- Key: Variable name (will be prefixed with
QOVERY_OUTPUT_JOB_<JOB_ID>_) - sensitive: Boolean indicating if value is sensitive
- value: The actual value to inject
Variable Naming
Output variables are automatically prefixed:API_KEY, it will be available as:
Using Output Variables
After the Lifecycle Job completes, output variables are automatically available to all services in the environment via environment variables.Force Run
Manually trigger a Lifecycle Job with a specific event type:Force Run allows testing specific event types without triggering the full environment lifecycle event.
Clone Service
You can create a clone of the service via the clone feature. A new service with the same configuration will be created into the target environment.The target environment can be the same as the current environment or a different one in a completely different project.
Cloning excludes custom domains and some built-in environment variables to prevent conflicts.
Delete Lifecycle Job
To delete a Lifecycle Job:- Navigate to the Lifecycle Job settings
- Click Delete
- Confirm deletion
Related Resources
Database Seeding Guide
Learn how to seed databases with Lifecycle Jobs
Cron Jobs
Schedule periodic jobs with CRON syntax
Environment Variables
Manage configuration and secrets
Deployment Pipeline
Understand deployment flow and lifecycle