> 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/gitlab-ci-cd/configuring-github.md).

# Configure Gitlab

## Prerequisites

To interact with your Duplocloud Portal from GitLab CI/CD, you need to follow these steps.

### 1. Create Service Account

First you need a service account in your portal which has the needed permissions.

{% content-ref url="/pages/VwCngnlYlKcKUkSXnI7J" %}
[Service Accounts](/docs/automation-platform/introduction-to-ci-cd/service-accounts.md)
{% endcontent-ref %}

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

### 2. Save The Variables

Now we can save the information about the service account within the Gitlab CI/CD Environment variables. You mainly need to set `DUPLO_HOST` and `DUPLO_TOKEN` variables.

{% hint style="info" %}
If using GKE or Azure you will also need `CLOUD_CREDENTIALS` and `CLOUD_ACCOUNT` which you obtain when creating a service account in step 1.
{% endhint %}

#### [Limit Level Scope](https://docs.gitlab.com/ee/ci/variables/#for-a-project)

Gitlab does have the option to set these variables at a variety of level scopes; organization, group, project. For example, you can set variables at the organization level and then all projects would be able to interact with your portal.

#### [Limit Environment Scope](https://docs.gitlab.com/ee/ci/environments/index.html#limit-the-environment-scope-of-a-cicd-variable)

Gitlab has a unique feature to scope variables into tiers as well. This is very useful when you have many instances of an app within some tiers like dev, stage, prod. With this you can scope a variable like this `dev/*` which means any [Gitlab Environment ](https://docs.gitlab.com/ee/ci/environments/)with that prefix will inherit this variable. This means you can make all dev environments share the `DUPLO_HOST` variable. This can group tenants under namespace as well, so you can rename your `dev01` tenant to be a `dev/dev01` to be an environment under a tier in Gitlab CI. This is particularly useful with multiple Duplocloud Portals.<br>

<figure><img src="/files/ZPuFwI0615L9NHJX1oT4" alt=""><figcaption><p>Create a secret variable in Gitlab CI</p></figcaption></figure>

{% hint style="warning" %}
The rest of this documentation will assume all the variables needed for service account access are set.
{% endhint %}

## References

* [Gitlab CI/CD Docs](https://docs.gitlab.com/ee/topics/build_your_application.html)
* [Using Gitlab Environments](https://docs.gitlab.com/ee/ci/environments/)
* [Create Duplocloud Users](/docs/automation-platform/access-control/user-access-and-permissions/add-edit-or-delete-a-user.md)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.duplocloud.com/docs/automation-platform/introduction-to-ci-cd/gitlab-ci-cd/configuring-github.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
