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

# GitLab Integration

export const NeedHelpFooter = ({provider, troubleshootingText = "troubleshooting steps"}) => {
  return <p>
      <strong>Need help?</strong> If you encounter any issues setting up the {provider} integration, please contact our support team or visit our documentation for {troubleshootingText}.
    </p>;
};

export const ManagingIntegration = ({provider, settingsPath = "Settings → Integrations", actionText = "Configure or Disconnect"}) => {
  return <>
      <h2>Managing the Integration</h2>
      <p>To disconnect or modify the {provider} integration:</p>
      <ol>
        <li>Go to Codemod <strong>{settingsPath}</strong></li>
        <li>Find your {provider} integration and click <strong>{actionText}</strong></li>
      </ol>
    </>;
};

Connect Codemod to your GitLab repositories to enable automated code transformations across your codebase.

## Why integrate GitLab?

Integrating Codemod with GitLab allows you to apply codemods directly to your repositories and create merge requests with automated code changes. Our GitLab integration supports GitLab.com and uses secure token-based authentication.

## Set up the integration

<Steps>
  <Step title="Navigate to add organization">
    Sign in to [Codemod](https://app.codemod.com). Click on team switcher and click on "Add Organization"

    <img src="https://mintcdn.com/codemod/FPj880CXGC9OFtxA/images/integrations/github-step-add-org-dark.png?fit=max&auto=format&n=FPj880CXGC9OFtxA&q=85&s=b149241f490456b0e200361d665d3be4" alt="Screenshot of how you can add organization in Codemod platform" title="Screenshot of how you can add organization in Codemod platform" className="hidden dark:block mx-auto" style={{ width:"58%" }} width="960" height="540" data-path="images/integrations/github-step-add-org-dark.png" />

    <img src="https://mintcdn.com/codemod/FPj880CXGC9OFtxA/images/integrations/github-step-add-org-light.png?fit=max&auto=format&n=FPj880CXGC9OFtxA&q=85&s=7258414f851ff54cdfb5016004a38fa3" alt="Screenshot of how you can add organization in Codemod platform" title="Screenshot of how you can add organization in Codemod platform" className="block dark:hidden mx-auto" style={{ width:"58%" }} width="960" height="540" data-path="images/integrations/github-step-add-org-light.png" />
  </Step>

  <Step title="Select GitLab provider">
    Choose **GitLab** as your Git provider from the available options.

    <img src="https://mintcdn.com/codemod/FVgEvcDTlFQCTDab/images/integrations/gitlab-step-connect-dark.png?fit=max&auto=format&n=FVgEvcDTlFQCTDab&q=85&s=cd408608e643d83e9794a942fc326d4b" alt="Screenshot of the create organization page in Codemod platform with GitLab option selected" title="Screenshot of the create organization page in Codemod platform with GitLab option selected" className="hidden dark:block mx-auto" style={{ width:"58%" }} width="1440" height="720" data-path="images/integrations/gitlab-step-connect-dark.png" />

    <img src="https://mintcdn.com/codemod/FVgEvcDTlFQCTDab/images/integrations/gitlab-step-connect-light.png?fit=max&auto=format&n=FVgEvcDTlFQCTDab&q=85&s=db1cdd969104c2f9010f248d926572c6" alt="Screenshot of the create organization page in Codemod platform with GitLab option selected" title="Screenshot of the create organization page in Codemod platform with GitLab option selected" className="block dark:hidden mx-auto" style={{ width:"58%" }} width="1440" height="720" data-path="images/integrations/gitlab-step-connect-light.png" />
  </Step>

  <Step title="Create a GitLab access token">
    Before proceeding, you'll need to create a GitLab Group Access Token. Refer to [this guide](https://docs.gitlab.com/user/group/settings/group_access_tokens/) to create a group access token. Follow these steps:

    **Creating a group access token (recommended):**

    **Navigate to your GitLab group**: Go to GitLab.com and navigate to your group that contains the repositories you want to integrate.

    **Access token settings**: In the left sidebar, go to **Settings** → **Access Tokens**

    **Create new token**:

    1. Click **"Add new token"**
    2. Enter a name (e.g., "Codemod Integration")
    3. Set an expiration date (optional but recommended)
    4. Select the required scopes (see below)
    5. Click **"Create group access token"**

    **Copy the token**: Copy the generated token immediately. You won't be able to see it again!

    <Warning>
      Make sure to copy the token right away. GitLab will only show it once for security reasons.
    </Warning>

    <Info>
      <b>Alternative: Personal access token</b><br />
      If you don't have group admin permissions, you can create a <a href="https://gitlab.com/-/profile/personal_access_tokens" target="_blank">personal access token</a> instead. However, group access tokens are recommended as they're not tied to individual users.
    </Info>
  </Step>

  <Step title="Configure required token scopes">
    Your GitLab token must have the following scopes:

    <ParamField path="read_user" type="scope" required>
      Allows reading user information and group memberships
    </ParamField>

    <ParamField path="write_repository" type="scope" required>
      Enables creating branches, commits, and merge requests
    </ParamField>

    <ParamField path="api" type="scope" required>
      Provides full API access for repository operations
    </ParamField>

    <img src="https://mintcdn.com/codemod/FVgEvcDTlFQCTDab/images/integrations/gitlab-step-create-token-dark.png?fit=max&auto=format&n=FVgEvcDTlFQCTDab&q=85&s=2f7aa24749876dc8570bdd7df541c06e" alt="Screenshot of the create token page in GitLab with the required scopes selected" title="Screenshot of the create token page in GitLab with the required scopes selected" className="hidden dark:block mx-auto" style={{ width:"58%" }} width="2277" height="2070" data-path="images/integrations/gitlab-step-create-token-dark.png" />

    <img src="https://mintcdn.com/codemod/FVgEvcDTlFQCTDab/images/integrations/gitlab-step-create-token-light.png?fit=max&auto=format&n=FVgEvcDTlFQCTDab&q=85&s=7d2873d4711fc90dca17b457b9b1aa46" alt="Screenshot of the create token page in GitLab with the required scopes selected" title="Screenshot of the create token page in GitLab with the required scopes selected" className="block dark:hidden mx-auto" style={{ width:"58%" }} width="2281" height="2070" data-path="images/integrations/gitlab-step-create-token-light.png" />
  </Step>

  <Step title="Complete organization setup">
    Back in Codemod, fill in the organization details:

    1. **Organization Name**: Enter your organization's display name
    2. **Organization Slug**: Choose a unique URL-friendly identifier
    3. **GitLab Group Access Token**: Paste the token you created

    <img src="https://mintcdn.com/codemod/FVgEvcDTlFQCTDab/images/integrations/gitlab-step-create-org-page-dark.png?fit=max&auto=format&n=FVgEvcDTlFQCTDab&q=85&s=b5f5fe5cfef5825f2bcd538652260f5b" alt="Screenshot of Codemod organization creation form with GitLab fields" title="Screenshot of Codemod organization creation form with GitLab fields" className="hidden dark:block mx-auto" style={{ width:"58%" }} width="1408" height="910" data-path="images/integrations/gitlab-step-create-org-page-dark.png" />

    <img src="https://mintcdn.com/codemod/FVgEvcDTlFQCTDab/images/integrations/gitlab-step-create-org-page-light.png?fit=max&auto=format&n=FVgEvcDTlFQCTDab&q=85&s=f9f0b8f9bbc6d8ef51509255cde3efe0" alt="Screenshot of Codemod organization creation form with GitLab fields" title="Screenshot of Codemod organization creation form with GitLab fields" className="block dark:hidden mx-auto" style={{ width:"58%" }} width="1408" height="910" data-path="images/integrations/gitlab-step-create-org-page-light.png" />

    <Info>
      All tokens are encrypted both in our database and during transfer to ensure maximum security.
    </Info>

    Click **"Create Organization"** to complete the setup.
  </Step>
</Steps>

## Using the GitLab integration

Once connected, you can:

* Select connected repositories when running codemods
* Automatically create merge requests with your code transformations
* Configure which repositories to target for specific codemods
* Monitor the status of your automated code changes

## Managing your integration

### Updating access tokens

To update or rotate your GitLab access token:

1. Create a new token in GitLab following the same steps above
2. Go to Codemod **Settings** → **Integrations**
3. Click **Configure** next to the GitLab integration
4. Enter the new token and save

### Repository access

The integration will have access to all repositories within the GitLab group where you created the access token. To modify access:

1. In GitLab, go to your group's **Settings** → **Access Tokens**
2. Find your Codemod token and click **Revoke** to remove access
3. Create a new token if you want to grant access to different repositories

### Managing team members

Add team members to your organization to collaborate on migrations and control access to Campaigns and Insights.

<Note>
  If your organization uses [SAML SSO](/platform/saml#user-provisioning-and-access-control), users are provisioned automatically on first login (JIT) and access is controlled through your IdP — you do not need to invite them manually. Use the steps below to manage roles for users who already exist, or to invite users when SSO is not in use.
</Note>

<Steps>
  <Step title="Navigate to Organization Settings">
    Go to **Organization Settings** → **Members** in the Codemod app.
  </Step>

  <Step title="Invite team members">
    Click **Invite Members** and enter the email addresses of team members you want to add.
  </Step>

  <Step title="Assign roles">
    Assign one of the following roles to each team member:

    * **Admin**: Full access to organization settings and features
    * **Member**: Can create and manage Campaigns, view Insights
    * **Viewer**: Read-only access to Campaigns and Insights
  </Step>
</Steps>

## Security considerations

<Warning>
  Keep your GitLab access token secure and never share it publicly or commit it to version control.
</Warning>

* **Token Security**: All tokens are encrypted at rest and in transit using industry-standard encryption
* **Minimal Permissions**: Only grant the required scopes listed above
* **Regular Rotation**: Consider rotating tokens regularly for enhanced security
* **Review Access**: Regularly review which repositories have access in your GitLab group settings
* **Merge Request Review**: All code transformations are submitted as merge requests for your review before merging

### Branch protection

We recommend enabling merge request approvals and branch protection on your main branches to ensure changes are reviewed before merging.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Token authentication failed">
    * Verify your token has the correct scopes: `read_user`, `write_repository`, and `api`
    * Check that the token hasn't expired
    * Ensure you're using a group access token for the correct GitLab group
    * Make sure the token wasn't revoked in GitLab
  </Accordion>

  <Accordion title="Cannot access repositories">
    * Confirm the token belongs to a group that contains your repositories
    * Check that the repositories exist and you have the necessary permissions
    * Verify the group access token has sufficient permissions in the group settings
  </Accordion>

  <Accordion title="Merge requests not being created">
    * Ensure the target branch exists and is not protected without proper permissions
    * Check that the token has `write_repository` scope
    * Verify there are no branch protection rules preventing the token from creating merge requests
  </Accordion>
</AccordionGroup>

<ManagingIntegration provider="GitLab" />

To revoke access from GitLab's side:

1. Go to your GitLab group's **Settings** → **Access Tokens**
2. Find the Codemod token and click **Revoke**

***

<NeedHelpFooter provider="GitLab" troubleshootingText="additional troubleshooting steps" />
