> 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/troubleshooting-and-resources/resources/integrating-cd-other-modules.md).

# CD integration with other Harness modules

Learn how the CD module works with other Harness modules.

This topic describes a few of the cross-module use cases in the Harness platform.

***

## What you will learn from this topic

* How to couple a Harness Continuous Integration (CI) stage with a Harness Continuous Delivery (CD) stage to build, push, and deploy an application.
* Understand how [Harness Chaos Engineering (HCE)](#harness-chaos-engineering) experiments run as part of a CD pipeline.
* How to [manage feature flags](#harness-feature-management-and-experimentation) from within a CD pipeline.

***

## Harness Continuous Integration <a href="#harness-continuous-integration" id="harness-continuous-integration"></a>

You can couple Harness Continuous Integration (CI) and Continuous Delivery (CD) in a single pipeline.

You can use Harness CI as the first stage in the pipeline to build, test, and push your app to a repo, and then have a subsequent CD stage pull that app version from the repo and deploy it to a dev, QA, or prod environment.

The following YAML is a simple example that builds and pushes an app in the CI stage and then pulls and deploys the app in the CD stage.

<details>

<summary>YAML</summary>

```yaml
pipeline:
  name: tweety
  identifier: tweety
  projectIdentifier: <PROJECT_ID>
  orgIdentifier: default
  tags: {}
  properties:
    ci:
      codebase:
        connectorRef: <GIT_CONNECTOR_ID>
        build: <+input>
  stages:
    - stage:
        name: Tweetapp
        identifier: Tweetapp
        type: CI
        spec:
          cloneCodebase: true
          infrastructure:
            type: KubernetesDirect
            spec:
              connectorRef: <KUBERNETES_CONNECTOR_ID>
              namespace: default
              automountServiceAccountToken: true
              nodeSelector: {}
              os: Linux
          execution:
            steps:
              - step:
                  type: BuildAndPushDockerRegistry
                  name: Build Tweet App
                  identifier: Build_Tweet_App
                  spec:
                    connectorRef: <DOCKER_CONNECTOR_ID>
                    repo: <DOCKER_HUB_USERNAME>/<REPOSITORY_NAME>
                    tags:
                      - <+pipeline.sequenceId>
          service:
            serviceRef: ""
        variables: []
    - stage:
        name: deploy tweety
        identifier: deploy_tweety
        description: ""
        type: Deployment
        spec:
          deploymentType: Kubernetes
          service:
            serviceRef: Tweety
          environment:
            environmentRef: Tweety
            deployToAll: false
            infrastructureDefinitions:
              - identifier: Tweety
          execution:
            steps:
              - step:
                  name: Rollout Deployment
                  identifier: rolloutDeployment
                  type: K8sRollingDeploy
                  timeout: 10m
                  spec:
                    skipDryRun: false
                    pruningEnabled: false
            rollbackSteps:
              - step:
                  name: Rollback Rollout Deployment
                  identifier: rollbackRolloutDeployment
                  type: K8sRollingRollback
                  timeout: 10m
                  spec:
                    pruningEnabled: false
        tags: {}
        failureStrategies:
          - onFailure:
              errors:
                - AllErrors
              action:
                type: StageRollback
        when:
          pipelineStatus: Success
  allowStageExecutions: true
```

</details>

The following tabs show the pipeline in Pipeline Studio.

{% tabs %}
{% tab title="CI stage" %}
The following image shows the push step from the CI stage.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-1bebbdb50515b2d21a2d0eeb0c6230c2654719da%2Ff2f3a47b93bed917ba2df30fc996ee9a859119c2ce7288eebbf0c8e9d81d8f0d.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

Note the `<+pipeline.sequenceId>` expression. This is used to tag the artifact pushed to Docker Hub. You can tag your artifact versions in a number of ways. The expression `<+pipeline.sequenceId>` increments each time the pipeline runs.

The subsequent CD stage uses the expression `<+pipeline.sequenceId>` to fetch the app version.
{% endtab %}

{% tab title="CD stage" %}
The following image shows the Kubernetes Rollout Deployment step from the CD stage.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-97dcdea216f5d1cbf4bed6adcd97bffbb81c8803%2Fd3f2a764bed2a191ddb13ae8c4f2a607da97c7aa22e94f433eeac946da54cb15.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

In the stage's service, the expression `<+pipeline.sequenceId>` is used to pull the app version.

![Service artifact configuration that uses the pipeline.sequenceId expression](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-776701c19a5347a7d506ceed21622a8fba19bef3%2F3c2e1bbbaf91a9d3da0487bbeb2919ae045b1718fe2c20bba220efcc4a86a439.png?alt=media)
{% endtab %}
{% endtabs %}

This example is a simple introduction to the integration. For a longer tutorial of Harness CI and CD integration, go to [End-To-End CI/CD Pipeline](/continuous-delivery/troubleshooting-and-resources/tutorials/kubernetes-container-deployments/e2e-pipeline.md).

## Harness Chaos Engineering <a href="#harness-chaos-engineering" id="harness-chaos-engineering"></a>

The [Harness Chaos Engineering (HCE) integration with Harness CD](https://developer.harness.io/resilience-testing/chaos-engineering/integrations/cicd/harness-cd) lets you run chaos experiments as part of a Harness CD pipeline.

## Harness Feature Management & Experimentation <a href="#harness-feature-management-and-experimentation" id="harness-feature-management-and-experimentation"></a>

You can integrate [Harness Feature Management & Experimentation](https://developer.harness.io/feature-management-experimentation) into your [Harness CD pipelines](https://developer.harness.io/feature-management-experimentation/management-and-administration/pipelines) to manage feature flags as part of your deployment workflow.

By adding FME steps to CD stages, you can create, update, target, and disable feature flags during a pipeline execution. This lets you version, review, and run feature flag operations alongside application deployments, reducing manual steps and improving release coordination.

You can integrate Harness FME with CD pipelines in the following ways:

* Creating or updating feature flags as part of a release
* Managing individual targeting lists during staged rollouts
* Adjusting default traffic allocations when deploying a new version
* Killing a feature flag immediately in response to deployment issues

For more information, go to [Pipelines documentation](https://developer.harness.io/feature-management-experimentation/management-and-administration/pipelines).

***

## Next steps

* [End-To-End CI/CD Pipeline](/continuous-delivery/troubleshooting-and-resources/tutorials/kubernetes-container-deployments/e2e-pipeline.md): A longer tutorial covering Harness CI and CD integration.
* [Services and environments overview](/continuous-delivery/new-to-continuous-delivery/overview.md): Review how services and environments work in Harness CD.

{% @harness-feedback/feedback %}
