DocsLifecycle schemaCodefresh Service

Codefresh Service

Trigger external Codefresh pipelines for deployment and teardown.

The codefresh Service uses external Codefresh pipelines for deployment. Use it when existing CI/CD pipelines contain complex build and deployment logic.

Example

Required fields

FieldTypeDescription
repositorystringGitHub repository in owner/repo format
branchNamestringBranch to build from
deploy.pipelineIdstringCodefresh pipeline ID for deployment
destroy.pipelineIdstringCodefresh pipeline ID for destruction

Optional fields

FieldTypeDescription
envobjectEnvironment variables passed to pipelines
deploy.triggerstringPipeline trigger name for deployment
destroy.triggerstringPipeline trigger name for destruction
⚠️

Set repository, branchName, and both pipeline IDs. A missing pipeline ID causes the related deployment or teardown operation to fail.

Authentication

Before you run Codefresh Services or the Docker ci builder, configure CODEFRESH_API_KEY in Lifecycle. Ask the operator to supply this credential through the approved Secret process. Use the same process to rotate it. Do not put it in lifecycle.yaml.

Pipeline configuration

deploy

Configure the pipeline that deploys the Service.

destroy

Configure the pipeline that tears down the Environment.

Environment variables

Pass environment variables to the deploy and destroy pipelines:

Environment variables in env go to the deploy and destroy pipelines. Template variables can refer to other Services. Full-value cloud secret references resolve before invocation. More information is in Cloud Secrets.

How it works

  1. When Lifecycle deploys an Environment, it triggers the deploy pipeline with the configured environment variables.
  2. The pipeline receives the branch, namespace, and Service information.
  3. When Lifecycle tears down the Environment, it triggers the destroy pipeline to remove resources.

Typical tasks

  • Complex builds — Multi-stage pipelines or custom tooling.
  • External dependencies — Deployments that interact with external systems.
  • Existing CI/CD — Established Codefresh pipelines.
  • Custom deployment logic — Deployments that standard Kubernetes configuration cannot express.
⚠️

Codefresh pipelines run asynchronously. Lifecycle tracks pipeline status but Codefresh manages the deployment logic.

Find pipeline IDs

To find your Codefresh pipeline ID:

  1. Open your pipeline in Codefresh.
  2. Find the pipeline ID in the URL: https://g.codefresh.io/pipelines/edit/new/.../<pipeline-id>.
  3. Or, run codefresh get pipelines.