GitLab CI
OpenCode works in a regular GitLab pipeline. You can build it into a pipeline as a CI component. Here we are using a community-created CI/CD component for OpenCode — nagyv/gitlab-opencode.Features
- Use custom configuration per job: Configure OpenCode with a custom configuration directory, for example
./config/#custom-directoryto enable or disable functionality per OpenCode invocation. - Minimal setup: The CI component sets up OpenCode in the background, you only need to create the OpenCode configuration and the initial prompt.
- Flexible: The CI component supports several inputs for customizing its behavior.
Setup
Store authentication credentials
Store your OpenCode authentication JSON as a File type CI environment variable under Settings > CI/CD > Variables. Make sure to mark them as “Masked and hidden”.
GitLab Duo
OpenCode integrates with your GitLab workflow through GitLab Duo. Mention@opencode in a comment, and OpenCode will execute tasks within your GitLab CI pipeline.
Features
- Triage issues: Ask OpenCode to look into an issue and explain it to you.
- Fix and implement: Ask OpenCode to fix an issue or implement a feature. It will create a new branch and raise a merge request with the changes.
- Secure: OpenCode runs on your GitLab runners.
Setup
OpenCode runs in your GitLab CI/CD pipeline, here’s what you’ll need to set it up:Configure CI/CD variables
Store your API keys and tokens as CI/CD variables in your GitLab project settings.
Usage Examples
Here are some examples of how you can use OpenCode in GitLab.Explain an Issue
Add this comment in a GitLab issue:Fix an Issue
In a GitLab issue, say:Review Merge Requests
Leave the following comment on a GitLab merge request:FAQ
Can I use OpenCode with GitLab.com?
Can I use OpenCode with GitLab.com?
Yes, OpenCode works with both GitLab.com and self-hosted GitLab instances.
Do I need GitLab Duo to use OpenCode?
Do I need GitLab Duo to use OpenCode?
No, you can use OpenCode through the GitLab CI component without GitLab Duo. However, GitLab Duo provides a more integrated experience with
@opencode mentions.Can OpenCode work with private repositories?
Can OpenCode work with private repositories?
Yes, OpenCode works with both public and private repositories on GitLab.
How do I customize the trigger phrase?
How do I customize the trigger phrase?
You can customize the trigger phrase in your flow configuration file. Change
@opencode to any other trigger phrase you prefer.What permissions does the service account need?
What permissions does the service account need?
The service account needs permissions to read repository content, create branches, create merge requests, and comment on issues and merge requests.