| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- ---
- title: GitLab
- description: Use opencode in GitLab issues and merge requests.
- ---
- opencode는 GitLab CI/CD 파이프라인 또는 GitLab Duo를 통해 GitLab 워크플로우와 통합됩니다.
- 두 경우, opencode는 GitLab runners에서 실행됩니다.
- ---
- #GitLab CI 소개
- opencode는 일반 GitLab 파이프라인에서 작동합니다. [CI 구성품](https://docs.gitlab.com/ee/ci/components/)로 파이프라인에 구축할 수 있습니다.
- 여기에서 우리는 opencode에 대한 커뮤니티 생성 CI / CD 구성품을 사용하고 있습니다. [nagyv/gitlab-opencode](https://gitlab.com/nagyv/gitlab-opencode).
- ---
- ### 특징
- - **일당 사용자 지정 구성 사용**: 사용자 정의 구성 디렉토리와 opencode 구성, 예를 들어 `./config/#custom-directory`는 opencode invocation 당 활성화하거나 비활성화 할 수 있습니다.
- - ** 최소 설정**: CI 구성 요소는 opencode를 배경으로 설정하면 opencode 구성과 초기 프롬프트를 만들 필요가 있습니다.
- - **Flexible**: CI 구성 요소는 여러 입력을 지원합니다.
- ---
- ## 설정
- 1. opencode 인증 JSON을 **Settings** > **CI/CD** > **Variables**에서 파일 유형 CI 환경 변수로 저장하십시오. "Masked and hidden"로 표시하십시오.
- 2. `.gitlab-ci.yml` 파일에 뒤에 추가하십시오.
- ```yaml title=".gitlab-ci.yml"
- include:
- - component: $CI_SERVER_FQDN/nagyv/gitlab-opencode/opencode@2
- inputs:
- config_dir: ${CI_PROJECT_DIR}/opencode-config
- auth_json: $OPENCODE_AUTH_JSON # The variable name for your OpenCode authentication JSON
- command: optional-custom-command
- message: "Your prompt here"
- ```
- 더 많은 입력 및 사용 사례 [docs를 체크 아웃](https://gitlab.com/explore/catalog/nagyv/gitlab-opencode) 이 구성 요소에 대한.
- ---
- ## GitLab 듀오
- opencode는 GitLab 워크플로우와 통합됩니다.
- 코멘트에 Mention `@opencode`, opencode는 GitLab CI 파이프라인 내에서 작업을 실행합니다.
- ---
- ### 특징
- - **문제**: opencode가 문제점을 보고 당신을 설명합니다.
- - **Fix 및 구현 **: 이슈를 수정하거나 기능을 구현하려면 opencode에 문의하십시오.
- 새로운 지점을 만들고 변화를 병합 요청을 제기합니다.
- - **Secure**: opencode는 GitLab runners에서 실행됩니다.
- ---
- ## 설정
- opencode는 GitLab CI/CD 파이프라인에서 실행되며, 여기서 설정해야 할 일은 다음과 같습니다.
- :::tip
- [**GitLab docs**](https://docs.gitlab.com/user/duo agent platform/agent assistant/) 를 체크 아웃하십시오.
- :::
- 1. GitLab 환경 설정
- 2. CI/CD 설치
- 3. AI 모형 공급자 API 열쇠를 얻으십시오
- 4. 서비스 계정 만들기
- 5. CI/CD 변수 구성
- 6. Flow config 파일을 만들려면 다음과 같습니다.
- <details>
- <summary>Flow configuration</summary>
- ```yaml
- image: node:22-slim
- commands:
- - 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_CONTEXT
- Task: $AI_FLOW_INPUT
- Event: $AI_FLOW_EVENT
- Please 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)" ]; then
- echo "Git changes detected, adding and pushing..."
- git add .
- if git diff --cached --quiet; then
- echo "No staged changes to commit"
- else
- echo "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_REF
- echo "Changes successfully pushed"
- fi
- else
- echo "No git changes detected, skipping push"
- fi
- variables:
- - ANTHROPIC_API_KEY
- - GITLAB_TOKEN_OPENCODE
- - GITLAB_HOST
- ```
- </details>
- 자세한 지침에 대한 [GitLab CLI Agent docs](https://docs.gitlab.com/user/duo agent platform/agent assistant/)를 참조할 수 있습니다.
- ---
- ### 예제
- 다음은 GitLab에서 opencode를 사용할 수있는 몇 가지 예입니다.
- :::tip
- `@opencode`보다 다른 트리거 구문을 사용할 수 있습니다.
- :::
- - **문제 설명**
- GitLab 문제에서이 코멘트를 추가하십시오.
- ```
- @opencode explain this issue
- ```
- opencode는 문제와 대답을 명확하게 설명합니다.
- - **문제**
- GitLab 문제에서, 말한다:
- ```
- @opencode fix this
- ```
- opencode는 새로운 지점을 만들 것이며 변경 사항을 구현하고 변경 사항을 병합 요청을 엽니다.
- - **Review 병합 요청**
- GitLab 병합 요청에 대한 다음 의견을 남겨주세요.
- ```
- @opencode review this merge request
- ```
- opencode는 병합 요청을 검토하고 피드백을 제공합니다.
|