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

# CI/CD Examples

> CI/CD integration examples for GitHub Actions, GitLab CI, Bitbucket Pipelines, and CircleCI. Covers building, testing, and deploying with Terraform or CLI.

Below are CI/CD examples for [GitHub](https://github.com), [GitLab](https://gitlab.com), [BitBucket](https://bitbucket.org), and [CircleCI](https://circleci.com). The examples illustrate using pipelines to automate the build, test and deploy phases. Two examples per source control system are provided. One using [Terraform](https://registry.terraform.io/providers/controlplane-com/cpln/latest/docs) and the other using the [CLI](/cli-reference/overview). The `README.md` in the examples provide instructions for using the respective pipeline. These examples are provided as a starting point and your own unique delivery and/or deployment requirements will dictate the steps needed in your situation.

## Terraform

Control Plane provides a Terraform plugin allowing you to build your Control Plane infrastructure declaratively. The following examples include the plugin installation instructions, containerizing and pushing an app to the org’s private [image registry](/reference/image) and a sample Terraform configuration file defining a [GVC](/reference/gvc) and a [workload](/reference/workload).

### Examples

* [GitHub](https://github.com/controlplane-com/github-actions-example-terraform)
* [GitLab](https://gitlab.com/controlplane-com/gitlab-pipeline-example-terraform)
* [Bitbucket](https://bitbucket.org/controlplane-com/bitbucket-pipeline-example-terraform)

<Note>
  - The GitHub and Bitbucket example uses the [Terraform Cloud](https://app.terraform.io/) to store the state file.

  - The GitLab example leverages their [managed Terraform state backend](https://docs.gitlab.com/ee/user/infrastructure/terraform_state.html) to store the state file.
</Note>

## CLI

The [CLI apply](/cli-reference/commands/apply) command creates and updates Control Plane resources. The command can be used in a pipeline to manage the deployment of an application. It takes as an input a JSON or YAML file containing the properties of the resource to manage.

The command can accept a YAML file containing multiple resources. Each resource must be separated using `---`. If a resource has a reference to another resource (e.g., a [workload](/reference/workload) refers to a [GVC](/reference/gvc)), the referenced resource must be defined in its own file and processed in order.

If the name of an exisiting resource is changed, the `cpln apply` command will create a new resource. Any orphaned resources will need to be manually deleted.

The examples below include installation of the [CLI](/cli-reference/installation), containerizing and pushing an application to the org's private repository. The examples contain two sample YAML files. One that manages a GVC, and one for a workload.

### Examples

* [GitHub](https://github.com/controlplane-com/github-actions-example-cli)
* [GitLab](https://gitlab.com/controlplane-com/gitlab-pipeline-example-cli)
* [Bitbucket](https://bitbucket.org/controlplane-com/bitbucket-pipeline-example-cli)
* [CircleCI](https://github.com/controlplane-com/circle-ci-pipeline-example-cli)
* [Google Cloud Build](https://github.com/controlplane-com/google-cloud-build-example-cli)

<Tip>
  Samples of existing resources can be exported using the console or the CLI. These samples can assist when defining resources for your application.

  Using the console, after selecting a resource, there will be an `Export` pull down button in the upper right corner. Select JSON or YAML to download the file.

  Using the CLI's `get` command for each resource, the `-o` flag can output the resource as JSON or YAML.

  For example: `cpln gvc get GVC_NAME -o yaml-slim --org ORG_NAME`
</Tip>
