> For the complete documentation index, see [llms.txt](https://docs.duplocloud.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.duplocloud.com/docs/automation-platform/introduction-to-ci-cd/circleci/configure-circleci.md).

# Configure CircleCI

## Prerequisites

### Deploying and testing the application

To use CircleCI CI/CD, you need to deploy the application with DuploCloud as a Service and test that it works as expected.

{% hint style="info" %}
CircleCI CI/CD is recommended only for upgrades of container images and to run tests that can be written to run before or after.
{% endhint %}

## Obtaining and configuring an API Token

In order to call a DuploCloud API from CircleCI, you need to obtain and configure an API token.

{% content-ref url="/pages/zvxXWkKvve6JAarJ8IUf" %}
[API Tokens](/docs/automation-platform/access-control/api-and-session-management/api-tokens.md)
{% endcontent-ref %}

1. **(Recommended)** Create a "service account" user in DuploCloud to own the API token.
2. Give the DuploCloud user access to the desired Tenant. See [adding Tenants to a user](/docs/automation-platform/access-control/user-access-and-permissions/tenant-access.md#adding-tenant-access-for-a-user).
3. Create an API token for that user. See [creating API Tokens](/docs/automation-platform/access-control/api-and-session-management/api-tokens.md).
4. Add a CircleCI Environment Variables in the Context created for the organization, to allow CircleCI pipelines to communicate with the DuploCloud Portal.

{% hint style="info" %}
**Note:** A 'service account' user in DuploCloud is just a user whose user name is not an email address, such as `github-bot` or `my-api-user`. These users are not able to log in.
{% endhint %}

## Adding Tenant access for users

{% content-ref url="/pages/A34D0TLlNcWVPzh5JJwB" %}
[Tenant Access for Users](/docs/automation-platform/access-control/user-access-and-permissions/tenant-access.md)
{% endcontent-ref %}

## Adding Environment Variables in the organization context

1. Login to the CircleCI portal and select your organization.
2. Click on **Organization Settings** in the left-hand sidebar.
3. Click on **Create Context** button and create context by providing a name.
4. Click on the newly created context and scroll to **Environment Variables** section.
5. Click **Add Environment Variable**.
6. Set an Environment Variable name and value for`DUPLO_HOST`(the value is the DuploCloud Portal URL).
7. Set an Environment Variable name and value for `DUPLO_TOKEN` (the value of the token created for the above service account).
8. After adding the environment variables you should see them displayed in the **Organization Settings** section below.

![](https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FKBOPok1V8wHR8YxCFys4%2Fcontext.png?alt=media\&token=8315ded9-3730-42d1-a6d4-6f39979b03d5)

{% hint style="warning" %}
The rest of this procedure assumes that you have added the above two environment variables.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.duplocloud.com/docs/automation-platform/introduction-to-ci-cd/circleci/configure-circleci.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
