GitLab Workflow
The GitLab Workflow extension integrates GitLab into Visual Studio Code. After you set up the extension, you can:
- View GitLab issues and merge requests.
View issues, comments, merge requests, and changed files in the VS Code sidebar,
or build a custom search
to meet your needs.
- Create and review merge requests.
- View security findings in your current branch
- Validate your GitLab CI/CD configuration locally with a command.
- Manage your pipelines. View your pipeline status
and open the related merge request. With advanced pipeline actions,
you can create, retry, or cancel a pipeline.
- View the job output. View the output of a running or finished job in an editor tab.
- Manage snippets. Create and insert snippets, and create snippet patches.
- Browse a GitLab repository directly
in Visual Studio Code without cloning it.
- Auto-complete GitLab CI/CD variables in your
.gitlab-ci.yml
pipeline file, and any file beginning with .gitlab-ci
and ending with .yml
or .yaml
, like .gitlab-ci.production.yml
.
If you face an issue, check out our troubleshooting page and if it's not listed, please report it.
Minimum supported version
- GitLab versions 16.1 and later. While many extension features might work with earlier versions, they are unsupported.
- GitLab Duo Code Suggestions requires both:
- GitLab version 16.8 or later.
- VS Code 1.82.0 or later.
- Security Findings requires GitLab Workflow version 3.74.0 or later, and GitLab Ultimate.
To find your GitLab version, visit /help
(like https://gitlab.com/help
).
Features
These features require you to set up your access token. See the Setup section for instructions.
Code Suggestions
Write code more efficiently by using generative AI to suggest code while you're developing. To learn more about this feature, see the
Code Suggestions documentation. With Code Suggestions, you get:
- Code Completion, which suggests completions for the current line you are typing. These suggestions usually have low latency.
- Code Generation, which generates code based on a natural-language code comment block. Responses for code generation are streamed in VS Code to quickly begin giving results.
Code Suggestions is a generative artificial intelligence (AI) model. GitLab selects the best-in-class large-language models for specific tasks. We use Google Vertex AI Code Models and Anthropic Claude for Code Suggestions.
No new additional data is collected to enable this feature. Private non-public GitLab customer data is not used as training data.
Learn more about Code Suggestion data usage.
Code Suggestions status icons
Use the status bar icon to see if code suggestions are enabled:
Status |
Icon |
Enabled |
|
Disabled |
|
Loading |
|
Error |
|
Set up Code Suggestions
To set up Code Suggestions:
- Ensure your GitLab instance and organization
meets all the requirements
to use Code Suggestions.
- Set up this extension and connect it to your instance.
- To verify Code Suggestions are working properly, open a file that uses an
officially supported language.
In the status bar, find the tanuki icon. The enabled icon () shows that Code Suggestions are enabled. For the full set of icons and their meanings, see Code Suggestions status icons.
To add more languages to Code Suggestions:
- Find your desired language in the list of
language identifiers
for VS Code. You need the Identifier for a later step.
- In VS Code, open the extension settings for GitLab Workflow:
- On the top bar, go to Code > Settings > Extensions.
- Search for GitLab Workflow in the list, and select the gear icon.
- Select Extension Settings.
- In your User settings, find
GitLab › Ai Assisted Code Suggestions: Additional Languages and select Add Item.
- In Item, add the language identifier, and select OK.
Accepting code suggestions
To accept suggestions, use the following keyboard shortcuts:
- To accept the entire suggestion, press Tab.
- To accept the suggestion word-by-word, press Command + → (right arrow).
You can also accept a single line using the context menu:
- To accept the suggestion line-by-line, select Accept Line.
You can assign different keyboard shortcuts for Accept Inline Suggestion, Accept Next Word Of Inline Suggestion, or Accept Next Line Of Inline Suggestion:
- Run the
Preferences: Open Keyboard Shortcuts
command.
- Find the shortcut you want to edit, and select the Change keybinding (pencil) icon.
- Enter your preferred keyboard shortcut, then press Enter.
Use Code Generation
To use Code Generation:
- Add a comment to a supported file type.
- In the comment, use natural language to describe the code you want to build.
- Press Enter to start generating code.
You can disable the streaming function, if needed.
Browse issues, review MRs
See your issues, MRs (including changed files) and other custom search results on a dedicated panel in the VS Code sidebar. Read more
See pipeline status, open MR and closing issue links in the status bar. Read more.
This pipeline status automatically updates so you don't need to open GitLab to see your pipeline status.
Advanced pipeline actions allow you to view pipeline on GitLab, create a new pipeline, retry or cancel current pipeline. Read more.
Commands
You can use Command Palette to run the commands.
GitLab: Search Project Issues (Supports Filters)
. Read more
GitLab: Search Project Merge Requests (Supports Filters)
. Read more
GitLab: Advanced Search (Issues, Merge Requests, Commits, Comments...)
. Read more
GitLab: Create Snippet
- Create a public, internal, or private snippet from an entire file or selection. Read more.
GitLab: Create Snippet Patch
- Create a .patch
file from the entire file, or a selection. Read more
GitLab: Insert Snippet
- Insert a single-file or multi-file project snippet. Read more.
GitLab: Compare Current Branch with Default Branch
- Compare your branch with the repository's default branch and view changes on GitLab. Read more.
GitLab: Open Active File on GitLab
- View active file on GitLab with highlighting active line number and selected text block. Read more.
GitLab: Validate GitLab CI/CD Config
- Validate GitLab CI/CD configuration file .gitlab-ci.yml
. Read more.
GitLab: Show Merged GitLab CI/CD Config
- Show a preview of the GitLab CI/CD configuration file .gitlab-ci.yml
with all includes resolved. Read more.
GitLab: Open Merge Request for Current Branch
GitLab: Show Issues Assigned to Me
- Open issues assigned to you on GitLab.
GitLab: Show Merge Requests Assigned to Me
- Open MRs assigned to you on GitLab.
GitLab: Open Current Project on GitLab
GitLab: Create New Issue on Current Project
GitLab: Create New Merge Request on Current Project
- Open the merge request page to create a merge request.
GitLab: Open Remote Repository
- Browse a remote GitLab repository. Read more.
GitLab: Open Active File on GitLab
GitLab: Copy Link to Active File on GitLab
GitLab: Remove Account from VS Code
GitLab: Toggle Code Suggestions
GitLab: Toggle Code Suggestions for current language
Commands this extension extends or integrates with:
Git: Clone
- Search for and clone projects for every GitLab instance you set up. Read more, Official Documentation
Git: Add Remote...
- Add existing projects as remote from every GitLab instance you set up.
Setup
This extension requires you to create a GitLab personal access token, and assign it to the extension:
- Install the extension from the Visual Studio Marketplace and enable it. If you use an unofficial version of VS Code, install the extension from the Open VSX Registry.
- To sign in to your GitLab instance, run the command GitLab: Authenticate.
- Open Visual Studio Code, then open the command palette by pressing Command + Shift + P.
- In the command palette, search for GitLab: Authenticate and press Enter.
- Select your GitLab instance URL from the offered options, or enter one manually.
- When manually adding an instance to URL to GitLab instance, paste the full URL to your
GitLab instance, including the
http://
or https://
. Press Enter to confirm.
- For GitLab.com, you can use the OAuth authentication method.
- If you don't use OAuth, use a Personal Access Token to log in.
- If you have an existing personal access token with
api
scope, select Enter an existing token to enter it.
- If you don't, select Create a token first, and the extension opens the PAT settings page for you.
If this method fails, follow the instructions in the GitLab documentation.
- Copy the token. For security reasons, this value is never displayed again, so you must copy this value now.
- Paste in your GitLab personal access token and press Enter. The token is not displayed, nor is it accessible to others.
The extension automatically 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. See Account management for more details.
The extension is ready to use. If your project has a pipeline for the last commit, and a merge request from your current branch, information about both is displayed in the Visual Studio Code status bar.
Set token with environment variables
If you often delete your VS Code storage (such as in Gitpod containers) you can create environment variables before starting VS Code. If you set the token in an environment variable you don't have to set the personal access token every time you delete your VS Code storage.
GITLAB_WORKFLOW_INSTANCE_URL
: GitLab instance URL (e.g. https://gitlab.com
).
GITLAB_WORKFLOW_TOKEN
: personal access token, which you created during setup.
The token configured in an environment variable is overridden if you configure a token for the same GitLab instance in the extension.
Extension settings
To learn how to change the VS Code Settings, read the official Settings documentation.
If you use self-signed certificates to connect to your GitLab instance, read the
community-contributed
settings for self-signed certificates.
gitlab.pipelineGitRemoteName
(default: null)
The name of the Git remote name corresponding to the GitLab repository with your pipelines. If set to null
or missing, then the extension uses the same remote as for the non-pipeline features.
gitlab.debug
(default: false)
Setting this option to true
enables debug mode. Debug mode improves error stack trace because the extension will use source maps to understand minified code. Debug mode also shows debug log messages in the extension logs.
gitlab.customQueries
Defines the search queries that retrieves the items shown on the GitLab Panel. See Custom Queries documentation for more details.
gitlab.duo.enabledWithoutGitlabProject
(default: true)
Set to true
to keep GitLab Duo features enabled if the extension can't retrieve the project's duoFeaturesEnabledForProject
setting. When false
, all GitLab Duo features are disabled if the extension can't retrieve the project's duoFeaturesEnabledForProject
setting.
The duoFeaturesEnabledForProject
setting is unavailable if:
- The project is not set up in the extension.
- The project is on a different GitLab instance than your current account.
- The file or folder you are working with isn't part of any GitLab project you have access to.
gitlab.duoCodeSuggestions.enabled
(default: true)
Toggle to enable or disable AI assisted code suggestions.
gitlab.duoCodeSuggestions.openTabsContext
(default: true)
Toggle to enable or disable sending of context across open tabs to improve Code Suggestions.
gitlab.duoCodeSuggestions.enabledSupportedLanguages
The supported languages for which to enable Code Suggestions.
By default, all supported languages are enabled.
gitlab.duoCodeSuggestions.additionalLanguages
(Experimental.) To expand the list of officially supported languages for Code Suggestions, provide an array of the language identifiers. This feature is experimental, and the code suggestions quality for the added languages might not be optimal.
Features in-depth
GitLab Workflow allows you to view issue details and comments right in the VS Code. Click an issue link from the VS Code sidebar to open a new tab with the issue details. You can also comment on the issue from VS Code.
You can use GitLab Slash Commands to perform actions directly from VS Code. For example, to assign an issue to @fatihacet
, simply add a comment /assign @fatihacet
inside VS Code.
Merge Request Reviews
GitLab Workflow enables you to review merge requests directly inside the editor:
- In VS Code, on the left-hand sidebar, go to Issues and Merge Requests.
- Select the appropriate merge request filter to view a list of merge requests.
- Expand a relevant merge request to view the description and files changed.
- Select a file to open it, and view the diff.
From the diff, you can:
- Review and create discussions.
- Resolve and unresolve these discussions.
- Delete and edit individual comments.
Extension will add a GitLab Workflow panel to sidebar of VS Code. The dedicated panel will allow you to see the list of your issues and MRs (you can decide the exact queries by using the custom queries). Also you will be able to see pipeline, MR and issue links for your current branch.
You can see the issue and MR details by clicking on the issue item or by expanding the MR item and clicking on "Description". When you expand the MR, you can see all the changed files. When you click on a changed file, the extension opens the MR diff.
View the job output
To view the output of a job directly in VS Code, on the left sidebar, select the job. The output is updated automatically. To view the latest output, select Scroll to Bottom.
Security findings
If your project includes Secure features, then security findings are displayed for the currently checked out branch after you've opened a merge request for that branch and scans have completed. Secure features must be configured.
Pipeline actions
One of the real power features of this extension is pipeline actions. This feature can be accessible from the status bar by clicking the pipeline status text or command palette and allows you to,
- View the latest pipeline on GitLab
- Create a new pipeline for your current branch
- Retry the last pipeline
- Cancel the last pipeline
Status bar: details
If your current project is a GitLab project, the extension will do the following things:
- Fetch pipeline of the last commit and show it on the status bar. Clicking this item will open the pipeline actions menu.
- Show open MR for current branch and show it on the status bar. Clicking this item will open MR on GitLab.
- Fetch closing issue of that MR and show it on the status bar. Clicking this item will open Issue on GitLab.
Compare with default branch
You can see changes on GitLab by comparing your branch with the repository's default branch.
Open active file
This command allows you to see active file on GitLab. Extension sends active line number and selected text block to GitLab UI so you can see them highlighted.
Validate GitLab CI/CD Configuration
Using this command, you can quickly validate GitLab CI/CD configuration.
Show merged GitLab CI/CD configuration
This command displays a preview of your merged CI/CD configuration file, with all includes and references resolved.
CI/CD variable autocompletion
Quickly find the CI/CD variable you are looking for with the CI/CD variable autocompletion.
Clone GitLab projects
This extension integrates with the built-in Git Extension and allows you to search for and clone projects from GitLab (command Git: Clone
).
- You can search for projects on each GitLab instance for which you added an access-token.
- Only projects where you are a member of are displayed.
- You can clone with SSH or HTTPS
- With HTTPS, your access token is used to clone the repository, fetch commits, and push commits. Access tokens are used this way for all GitLab projects that are cloned manually with HTTPS, then opened in VS Code.
NOTE: Using the access-token for cloning with HTTPS does not work with VS Code version 1.53.x (See discussion)
Browse a repository without cloning
See Browse a repository in read-only mode in the GitLab documentation.
Account management
In the extension, you can switch between multiple GitLab accounts. For example, you can add a personal account and work account for gitlab.com
, and another account for a self-managed instance like gitlab.gnome.org
.
How the account and project are selected
To determine which account to use, the extension uses your git remote
URL. However, sometimes multiple accounts and projects exist. In this case, the extension asks you to select a project and account. For example:
- If you have a single remote URL
git@gitlab.com:gitlab-org/gitlab-vscode-extension.git
, but two accounts for gitlab.com
(like @Alice
and @Bob
).
- If you have a single GitLab account (for example
@Alice
), but you have multiple remotes, like:
origin
: git@gitlab.com:gitlab-org/gitlab-vscode-extension.git
personal-fork
: git@gitlab.com:viktomas/gitlab-vscode-extension.git
In these cases, the extension needs your input to decide which GitLab project (represented by git remote
URL) and account it should use.
Change the selected project and account
In the GitLab Workflow panel, a (multiple projects) label indicates you must choose an account.
Click the label to select a project-account combination
The list Issues and Merge requests list is populated.
To change your choice, right-click the project label and select Clear selected project.
Roadmap
To learn more about this project's team, processes, and plans, see
the Create:Editor Extensions Group
page in the GitLab handbook.
For a list of all open issues in this project, see the
issues page
for this project.
Contribution
This extension is open source and hosted on GitLab. Contributions are more than welcome. Feel free to fork and add new features or submit bug reports. See CONTRIBUTING for more information.
A list of the great people who contributed this project, and made it even more awesome, is available. Thank you all! 🎉