# Deploy a CI/CD Pipeline via GitLab Self-Hosted

This guide walks you through deploying a CI/CD pipeline using a self-hosted GitLab instance on Elestio.

---

##### Prerequisites

Before you begin, make sure you have:

- A running self-hosted GitLab instance (e.g. `https://gitlab.example.com`)
- A **Personal Access Token (PAT)** with the **`api` scope** *(see note below)*
- A repository hosted on your GitLab instance
- An active project in Elestio

> ⚠️ **Important:** Only the `api` scope is required. Additional scopes like `read_repository` or `read_user` are not necessary when `api` is enabled.

<div class="qMYqUG_convSearchResultHighlightRoot" id="bkmrk-you-can-follow-our-d"><div class="" data-is-intersecting="true" data-turn-id-container="request-6a0724b4-a058-83eb-a8ea-9407a24296e0-2"><div class="relative w-full overflow-visible"><section class="text-token-text-primary w-full focus:outline-none has-data-writing-block:pointer-events-none [&:has([data-writing-block])>*]:pointer-events-auto R6Vx5W_threadScrollVars scroll-mb-[calc(var(--scroll-root-safe-area-inset-bottom,0px)+var(--thread-response-height))] scroll-mt-[calc(var(--header-height)+min(200px,max(70px,20svh)))]" data-scroll-anchor="false" data-testid="conversation-turn-4" data-turn="assistant" data-turn-id="request-6a0724b4-a058-83eb-a8ea-9407a24296e0-2" data-turn-id-container="request-6a0724b4-a058-83eb-a8ea-9407a24296e0-2" dir="auto"><p class="callout info">You can follow our <span style="color: rgb(230, 126, 35);">[documentation ](https://docs.elest.io/books/cicd-pipelines/page/gitlab-self-hosted-personal-access-token-setup)</span>to generate the PAT.</p>

</section></div></div></div>---

##### Step 1: Select Deployment Method

1. Open your project in the Elestio dashboard
2. Navigate to **CI/CD → Create Pipeline**
3. Under **Deployment Method**, select **GitLab**

[![image.png](https://docs.elest.io/uploads/images/gallery/2026-05/scaled-1680-/m83image.png)](https://docs.elest.io/uploads/images/gallery/2026-05/m83image.png)

---

##### Step 2: Choose Hosting Type

After selecting GitLab, choose your hosting type:

<table id="bkmrk-option-description-c"><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td>**Cloud**</td><td>Connect to GitLab.com via OAuth</td></tr><tr><td>**Self-Hosted**</td><td>Connect using your own GitLab instance and PAT</td></tr></tbody></table>

Select **Self-Hosted** to continue.

[![image.png](https://docs.elest.io/uploads/images/gallery/2026-05/scaled-1680-/KB4image.png)](https://docs.elest.io/uploads/images/gallery/2026-05/KB4image.png)

> Switching between Cloud and Self-Hosted will reset previously selected repositories and settings.

---

##### Step 3: Connect Your Self-Hosted GitLab Instance

Enter your connection details:

1. **GitLab Instance URL**
    
    
    - Example: `https://gitlab.example.com`
    - Must include protocol (`http://` or `https://`)
    - No trailing slash
2. **Personal Access Token (PAT)**
    
    
    - Paste your token (`glpat-xxxxxxxxxxxx`)
    - Field is masked for security
3. Click **Connect**

[![image.png](https://docs.elest.io/uploads/images/gallery/2026-05/scaled-1680-/hOzimage.png)](https://docs.elest.io/uploads/images/gallery/2026-05/hOzimage.png)

##### Expected result

- ✅ Connected message:  
    **“Connected as \[username\] on \[instance URL\]."**
- Repository selection UI loads automatically

##### If connection fails

Check:

- Instance is publicly reachable
- Token includes `api` scope
- Token has not expired

---

##### Step 4: Select a Repository

Once connected, the **Import Git Repository** section appears.

1. **Git Account**
    
    
    - Your connected account is pre-selected
    - Use **Add Git Account** to connect another instance
2. **Git Scope** *(if available)*
    
    
    - Select a user, group, or organization
3. **Repository List**
    
    
    - Search or browse repositories
    - Private repos show a 🔒 icon
    - Click **"Import"** on your chosen repository

[![image.png](https://docs.elest.io/uploads/images/gallery/2026-05/scaled-1680-/hN3image.png)](https://docs.elest.io/uploads/images/gallery/2026-05/hN3image.png)

<div class="qMYqUG_convSearchResultHighlightRoot" id="bkmrk-now%2C-click-%22next%2C%22%C2%A0t"><div class="" data-is-intersecting="true" data-turn-id-container="request-6a0724b4-a058-83eb-a8ea-9407a24296e0-3"><div class="relative w-full overflow-visible"><section class="text-token-text-primary w-full focus:outline-none has-data-writing-block:pointer-events-none [&:has([data-writing-block])>*]:pointer-events-auto R6Vx5W_threadScrollVars scroll-mb-[calc(var(--scroll-root-safe-area-inset-bottom,0px)+var(--thread-response-height))] scroll-mt-[calc(var(--header-height)+min(200px,max(70px,20svh)))]" data-scroll-anchor="false" data-testid="conversation-turn-6" data-turn="assistant" data-turn-id="request-6a0724b4-a058-83eb-a8ea-9407a24296e0-3" data-turn-id-container="request-6a0724b4-a058-83eb-a8ea-9407a24296e0-3" dir="auto">> Now, click **"Next,"** then choose the cloud provider, region, and plan. After that, configure the pipeline settings by selecting the application type, runtime, and port configuration to proceed with the deployment.

</section></div></div></div>---

##### Adding Additional Self-Hosted Accounts

To connect another GitLab instance:

1. Open the **Git Account** dropdown
2. Click **Add Git Account**
3. Enter:
    
    
    - Instance URL
    - Personal Access Token (`api` scope)
4. Click **Connect**

The new account becomes active immediately.

[![image.png](https://docs.elest.io/uploads/images/gallery/2026-05/scaled-1680-/vtZimage.png)](https://docs.elest.io/uploads/images/gallery/2026-05/vtZimage.png)

---

##### Troubleshooting

<table id="bkmrk-issue-likely-cause-f"><thead><tr><th>Issue</th><th>Likely Cause</th><th>Fix</th></tr></thead><tbody><tr><td>Connection fails</td><td>Invalid URL or token</td><td>Verify URL format and regenerate the PAT.</td></tr><tr><td>No repositories listed</td><td>Missing `api` scope</td><td>Recreate token with `api`</td></tr><tr><td>Branch not found</td><td>Empty repo or wrong branch</td><td>Ensure branch exists and has commits</td></tr></tbody></table>