GitLab
Use opencode in GitLab issues and merge requests.
opencode는 GitLab CI/CD 파이프라인 또는 GitLab Duo를 통해 GitLab 워크플로우와 통합됩니다.
두 경우, opencode는 GitLab runners에서 실행됩니다.
#GitLab CI 소개
opencode는 일반 GitLab 파이프라인에서 작동합니다. CI 구성품로 파이프라인에 구축할 수 있습니다.
여기에서 우리는 opencode에 대한 커뮤니티 생성 CI / CD 구성품을 사용하고 있습니다. nagyv/gitlab-opencode.
특징
- 일당 사용자 지정 구성 사용: 사용자 정의 구성 디렉토리와 opencode 구성, 예를 들어
./config/#custom-directory는 opencode invocation 당 활성화하거나 비활성화 할 수 있습니다. - ** 최소 설정**: CI 구성 요소는 opencode를 배경으로 설정하면 opencode 구성과 초기 프롬프트를 만들 필요가 있습니다.
- Flexible: CI 구성 요소는 여러 입력을 지원합니다.
설정
-
opencode 인증 JSON을 Settings > CI/CD > Variables에서 파일 유형 CI 환경 변수로 저장하십시오. “Masked and hidden”로 표시하십시오.
-
.gitlab-ci.yml파일에 뒤에 추가하십시오..gitlab-ci.yml include:- component: $CI_SERVER_FQDN/nagyv/gitlab-opencode/opencode@2inputs:config_dir: ${CI_PROJECT_DIR}/opencode-configauth_json: $OPENCODE_AUTH_JSON # The variable name for your OpenCode authentication JSONcommand: optional-custom-commandmessage: "Your prompt here"
더 많은 입력 및 사용 사례 docs를 체크 아웃 이 구성 요소에 대한.
GitLab 듀오
opencode는 GitLab 워크플로우와 통합됩니다.
코멘트에 Mention @opencode, opencode는 GitLab CI 파이프라인 내에서 작업을 실행합니다.
특징
- 문제: opencode가 문제점을 보고 당신을 설명합니다.
- **Fix 및 구현 **: 이슈를 수정하거나 기능을 구현하려면 opencode에 문의하십시오. 새로운 지점을 만들고 변화를 병합 요청을 제기합니다.
- Secure: opencode는 GitLab runners에서 실행됩니다.
설정
opencode는 GitLab CI/CD 파이프라인에서 실행되며, 여기서 설정해야 할 일은 다음과 같습니다.
-
GitLab 환경 설정
-
CI/CD 설치
-
AI 모형 공급자 API 열쇠를 얻으십시오
-
서비스 계정 만들기
-
CI/CD 변수 구성
-
Flow config 파일을 만들려면 다음과 같습니다.
Flow configuration
image: node:22-slimcommands:- echo "Installing opencode"- npm install --global opencode-ai- echo "Installing glab"- export GITLAB_TOKEN=$GITLAB_TOKEN_OPENCODE- apt-get update --quiet && apt-get install --yes curl wget gpg git && rm --recursive --force /var/lib/apt/lists/*- curl --silent --show-error --location "https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository" | bash- apt-get install --yes glab- echo "Configuring glab"- echo $GITLAB_HOST- echo "Creating OpenCode auth configuration"- mkdir --parents ~/.local/share/opencode- |cat > ~/.local/share/opencode/auth.json << EOF{"anthropic": {"type": "api","key": "$ANTHROPIC_API_KEY"}}EOF- echo "Configuring git"- git config --global user.email "opencode@gitlab.com"- git config --global user.name "OpenCode"- echo "Testing glab"- glab issue list- echo "Running OpenCode"- |opencode run "You are an AI assistant helping with GitLab operations.Context: $AI_FLOW_CONTEXTTask: $AI_FLOW_INPUTEvent: $AI_FLOW_EVENTPlease execute the requested task using the available GitLab tools.Be thorough in your analysis and provide clear explanations.<important>Please use the glab CLI to access data from GitLab. The glab CLI has already been authenticated. You can run the corresponding commands.If you are asked to summarize an MR or issue or asked to provide more information then please post back a note to the MR/Issue so that the user can see it.You don't need to commit or push up changes, those will be done automatically based on the file changes you make.</important>"- git checkout --branch $CI_WORKLOAD_REF origin/$CI_WORKLOAD_REF- echo "Checking for git changes and pushing if any exist"- |if ! git diff --quiet || ! git diff --cached --quiet || [ --not --zero "$(git ls-files --others --exclude-standard)" ]; thenecho "Git changes detected, adding and pushing..."git add .if git diff --cached --quiet; thenecho "No staged changes to commit"elseecho "Committing changes to branch: $CI_WORKLOAD_REF"git commit --message "Codex changes"echo "Pushing changes up to $CI_WORKLOAD_REF"git push https://gitlab-ci-token:$GITLAB_TOKEN@$GITLAB_HOST/gl-demo-ultimate-dev-ai-epic-17570/test-java-project.git $CI_WORKLOAD_REFecho "Changes successfully pushed"fielseecho "No git changes detected, skipping push"fivariables:- ANTHROPIC_API_KEY- GITLAB_TOKEN_OPENCODE- GITLAB_HOST
자세한 지침에 대한 [GitLab CLI Agent docs](https://docs.gitlab.com/user/duo agent platform/agent assistant/)를 참조할 수 있습니다.
예제
다음은 GitLab에서 opencode를 사용할 수있는 몇 가지 예입니다.
- 문제 설명
GitLab 문제에서이 코멘트를 추가하십시오.
@opencode explain this issueopencode는 문제와 대답을 명확하게 설명합니다.
- 문제
GitLab 문제에서, 말한다:
@opencode fix thisopencode는 새로운 지점을 만들 것이며 변경 사항을 구현하고 변경 사항을 병합 요청을 엽니다.
- Review 병합 요청
GitLab 병합 요청에 대한 다음 의견을 남겨주세요.
@opencode review this merge requestopencode는 병합 요청을 검토하고 피드백을 제공합니다.