Install and set up the GitLab Workflow extension for VS Code

To install the GitLab Workflow extension for VS Code:

Connect to GitLab

After you download and install the extension, connect it to your GitLab account.

Create a personal access token

If you are on GitLab Self-Managed, create a personal access token.

  1. On the left sidebar, select your avatar.
  2. Select Edit profile.
  3. On the left sidebar, select Access tokens.
  4. Select Add new token.
  5. Enter a name, description, and expiration date.
  6. Select the api scope.
  7. Select Create personal access token.

Authenticate with GitLab

Then authenticate with GitLab.

  1. Open the Command Palette:
    • For macOS, press Command+Shift+P.
    • For Windows or Linux, press Ctrl+Shift+P.
  2. Type GitLab: Authenticate and press Enter.
  3. Select your GitLab instance URL from the options, or enter one manually.
    • If you enter one manually, in URL to GitLab instance, paste the full URL, including the http:// or https://. Press Enter to confirm.
  4. Authenticate with GitLab. For GitLab.com, you can use the OAuth authentication method. If you don’t use OAuth, use a personal access token.

The extension matches your Git repository remote URL with the GitLab instance URL you specified for your token. If you have multiple accounts or projects, you can choose the one you want to use. For more details, see Switch GitLab accounts in VS Code.

Connect to your repository

To connect to your GitLab repository from VS Code:

  1. In VS Code, on the top menu, select Terminal > New Terminal.

  2. Clone your repository: git clone <repository>.

  3. Change to the directory where your repository was cloned and check out your branch: git checkout <branch_name>.

  4. Ensure your project is selected:

    1. On the left sidebar, select GitLab Workflow ( tanuki ).
    2. Select the project name. If you have multiple projects, select the one you want to work with.
  5. In the terminal, ensure your repository is configured with a remote: git remote -v. The results should look similar to:

    origin  git@gitlab.com:gitlab-org/gitlab.git (fetch)
    origin  git@gitlab.com:gitlab-org/gitlab.git (push)

    If no remote is defined, or you have multiple remotes:

    1. On the left sidebar, select Source Control ( branch ).
    2. On the Source Control label, right-click and select Repositories.
    3. Next to your repository, select the ellipsis ( ellipsis_h ), then Remote > Add Remote.
    4. Select Add remote from GitLab.
    5. Choose a remote.

The extension shows information in the VS Code status bar if both:

  • Your project has a pipeline for the last commit.
  • Your current branch is associated with a merge request.

Configure the extension

To configure settings, go to Settings > Extensions > GitLab Workflow.

By default, Code Suggestions and GitLab Duo Chat are enabled, so if you have the GitLab Duo add-on and a seat assigned, you should have access.

Code security

To configure the code security settings, go to Settings > Extensions > GitLab Workflow > Code Security.

  • To enable SAST scanning of the active file, select the Enable Real-time SAST scan checkbox.
  • Optional. To enable SAST scanning of the active file when you save it, select the Enable scanning on file save checkbox.

Install pre-release versions of the extension

GitLab publishes pre-release builds of the extension to the VS Code Extension Marketplace.

To install a pre-release build:

  1. Open VS Code.
  2. Under Extensions > GitLab Workflow, select Switch to Pre-release Version.
  3. Select Restart Extensions.
    1. Alternatively Reload Window to refresh any outdated webviews after updating.