GitLab
GitLab issues और merge requests में OpenCode का उपयोग करें।
OpenCode आपके GitLab CI/CD पाइपलाइन के माध्यम से या GitLab Duo के साथ आपके GitLab वर्कफ़्लो के साथ एकीकृत होता है।
दोनों ही मामलों में, OpenCode आपके GitLab runners पर चलेगा।
GitLab CI
OpenCode एक सामान्य GitLab पाइपलाइन में काम करता है। आप इसे एक CI component (opens in a new tab) के रूप में किसी पाइपलाइन में बना सकते हैं।
यहाँ हम OpenCode के लिए एक समुदाय-निर्मित CI/CD component का उपयोग कर रहे हैं — nagyv/gitlab-opencode (opens in a new tab)।
Features
- प्रति जॉब कस्टम कॉन्फ़िगरेशन का उपयोग करें: प्रति OpenCode इन्वोकेशन कार्यक्षमता को सक्षम या अक्षम करने के लिए OpenCode को एक कस्टम कॉन्फ़िगरेशन डायरेक्टरी के साथ कॉन्फ़िगर करें, उदाहरण के लिए
./config/#custom-directory। - न्यूनतम सेटअप: CI component पृष्ठभूमि में OpenCode को सेट करता है, आपको केवल OpenCode कॉन्फ़िगरेशन और प्रारंभिक प्रॉम्प्ट बनाने की आवश्यकता होती है।
- लचीला: CI component अपने व्यवहार को कस्टमाइज़ करने के लिए कई इनपुट का समर्थन करता है।
Setup
-
अपने OpenCode authentication JSON को Settings > CI/CD > Variables के अंतर्गत File प्रकार के CI environment variables के रूप में संग्रहीत करें। उन्हें "Masked and hidden" के रूप में चिह्नित करना सुनिश्चित करें।
-
अपनी
.gitlab-ci.ymlफ़ाइल में निम्नलिखित जोड़ें।.gitlab-ci.ymlinclude: - 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"
अधिक इनपुट और उपयोग मामलों के लिए इस component के docs देखें (opens in a new tab)।
GitLab Duo
OpenCode आपके GitLab वर्कफ़्लो के साथ एकीकृत होता है।
किसी टिप्पणी में @opencode का उल्लेख करें, और OpenCode आपके GitLab CI पाइपलाइन के भीतर कार्यों को निष्पादित करेगा।
Features
- Issues को ट्राइएज करें: OpenCode से किसी issue की जाँच करने और उसे आपको समझाने के लिए कहें।
- ठीक करें और लागू करें: OpenCode से किसी issue को ठीक करने या किसी फ़ीचर को लागू करने के लिए कहें। यह एक नई branch बनाएगा और परिवर्तनों के साथ एक merge request उठाएगा।
- सुरक्षित: OpenCode आपके GitLab runners पर चलता है।
Setup
OpenCode आपके GitLab CI/CD पाइपलाइन में चलता है, इसे सेट करने के लिए आपको ये चीज़ें चाहिए होंगी:
Tip: नवीनतम निर्देशों के लिए GitLab docs (opens in a new tab) देखें।
-
अपना GitLab environment कॉन्फ़िगर करें
-
CI/CD सेट करें
-
एक AI मॉडल प्रोवाइडर API key प्राप्त करें
-
एक service account बनाएँ
-
CI/CD variables कॉन्फ़िगर करें
-
एक flow config फ़ाइल बनाएँ, यहाँ एक उदाहरण है:
Flow configuration
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 "[email protected]" - 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
विस्तृत निर्देशों के लिए आप GitLab CLI agents docs (opens in a new tab) देख सकते हैं।
Examples
यहाँ कुछ उदाहरण दिए गए हैं कि आप GitLab में OpenCode का उपयोग कैसे कर सकते हैं।
Tip: आप
@opencodeके बजाय एक अलग ट्रिगर वाक्यांश का उपयोग करने के लिए कॉन्फ़िगर कर सकते हैं।
-
किसी issue को समझाएँ किसी GitLab issue में यह टिप्पणी जोड़ें।
@opencode explain this issueOpenCode issue को पढ़ेगा और एक स्पष्ट व्याख्या के साथ उत्तर देगा।
-
किसी issue को ठीक करें किसी GitLab issue में कहें:
@opencode fix thisOpenCode एक नई branch बनाएगा, परिवर्तनों को लागू करेगा, और परिवर्तनों के साथ एक merge request खोलेगा।
-
Merge requests की समीक्षा करें किसी GitLab merge request पर निम्नलिखित टिप्पणी छोड़ें।
@opencode review this merge requestOpenCode merge request की समीक्षा करेगा और फ़ीडबैक प्रदान करेगा।