Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

OpenCode GitLab

OpenCode GitLab

OpenCode can also integrate into GitLab workflows, automatically executing tasks in Issues, Merge Requests, and CI/CD pipelines.

Its core feature: runs on your GitLab Runner, enabling secure and controllable AI-automated development.

OpenCode GitLab = connect AI to CI/CD, automating code analysis, fixes, and reviews.


I. Integration overview

OpenCode has two main usage modes in GitLab:


II. GitLab CI integration (core method)

OpenCode can be integrated as a CI component into your pipeline for automated task execution.

Here a community component is used:


nagyv/gitlab-opencode

1. Features

2. Configuration steps

① Configure authentication info

In your GitLab project:


OPENCODE_AUTH_JSON

Requirements:


② Configure the pipeline

Create or modify in the project root:


.gitlab-ci.yml

Example:


include:
  - component: $CI_SERVER_FQDN/nagyv/gitlab-opencode/opencode@2
    inputs:
      config_dir: ${CI_PROJECT_DIR}/opencode-config
      auth_json: $OPENCODE_AUTH_JSON
      command: optional-custom-command
      message: "Explain the codebase structure"

③ Parameter description

Parameters Description
config_dir OpenCode config directory
auth_json Authentication info (API Key)
command Execution command (optional)
message Prompt

3. Use cases


III. GitLab Duo integration (comment trigger)

Similar to GitHub's /opencode, GitLab uses @opencode .

When you comment in an Issue or Merge Request:


@opencode your prompt

OpenCode will automatically execute tasks in GitLab CI

1. Features

Characteristics:

2. Configuration steps

To use @opencode, you need to complete the following configuration:

Explanation:

For details, refer to the official GitLab CLI Agents documentation (slightly different between versions).


IV. Common usage patterns

1. Explain an Issue


@opencode explain this issue

Automatically summarize problems and give explanations

2. Auto-fix an Issue


@opencode fix this

Automatically:

3. Review a Merge Request


@opencode review this merge request

Automatically analyze:


V. Advanced tips

1. Custom trigger words

You can think of @opencode Replace with other trigger keywords.

2. Task-level configuration

Through different config_dir, achieve:

3. Combined with CI automation

You can achieve:


VI. Security and best practices