GitLab
ใช้ OpenSploit ในปัญหา GitLab และรวมคำขอ
OpenSploit ทำงานร่วมกับเวิร์กโฟลว์ GitLab ของคุณผ่านไปป์ไลน์ GitLab CI/CD หรือกับ GitLab Duo
ในทั้งสองกรณี OpenSploit จะทำงานบน GitLab runners ของคุณ
GitLab CI
OpenSploit ทำงานในไปป์ไลน์ GitLab ปกติ คุณสามารถสร้างมันลงในไปป์ไลน์เป็น องค์ประกอบ CI
ที่นี่เรากำลังใช้คอมโพเนนต์ CI/CD ที่สร้างโดยชุมชนสำหรับ OpenSploit — nagyv/gitlab-opensploit
คุณสมบัติ
- ใช้การกำหนดค่าแบบกำหนดเองต่องาน: กำหนดค่า OpenSploit ด้วยไดเร็กทอรีการกำหนดค่าแบบกำหนดเอง เช่น
./config/#custom-directoryเพื่อเปิดหรือปิดฟังก์ชันการทำงานต่อการเรียกใช้ OpenSploit - การตั้งค่าขั้นต่ำ: องค์ประกอบ CI จะตั้งค่า OpenSploit ในเบื้องหลัง คุณเพียงแค่ต้องสร้างการกำหนดค่า OpenSploit และข้อความแจ้งเริ่มต้นเท่านั้น
- ยืดหยุ่น: ส่วนประกอบ CI รองรับอินพุตหลายอินพุตเพื่อปรับแต่งลักษณะการทำงาน
ตั้งค่า
-
จัดเก็บการรับรองความถูกต้อง OpenSploit ของคุณ JSON เป็นประเภทไฟล์ CI ตัวแปรสภาพแวดล้อมภายใต้ การตั้งค่า > CI/CD > ตัวแปร ตรวจสอบให้แน่ใจว่าได้ทำเครื่องหมายว่าเป็น “ปิดบังและซ่อนไว้”
-
เพิ่มสิ่งต่อไปนี้ในไฟล์
.gitlab-ci.ymlของคุณ.gitlab-ci.yml include:- component: $CI_SERVER_FQDN/nagyv/gitlab-opensploit/opensploit@2inputs:config_dir: ${CI_PROJECT_DIR}/opensploit-configauth_json: $OPENCODE_AUTH_JSON # The variable name for your OpenSploit authentication JSONcommand: optional-custom-commandmessage: "Your prompt here"
หากต้องการข้อมูลเพิ่มเติมและกรณีการใช้งาน ตรวจสอบเอกสาร สำหรับส่วนประกอบนี้
GitLab Duo
OpenSploit ทำงานร่วมกับเวิร์กโฟลว์ GitLab ของคุณ
พูดถึง @opensploit ในความคิดเห็น แล้ว OpenSploit จะดำเนินการงานภายในไปป์ไลน์ GitLab CI ของคุณ
คุณสมบัติ
- Issue Triage: ขอให้ OpenSploit ตรวจสอบปัญหาและอธิบายให้คุณทราบ
- แก้ไขและนำไปใช้: ขอให้ OpenSploit แก้ไขปัญหาหรือใช้ฟีเจอร์ มันจะสร้างสาขาใหม่และขอรวมการเปลี่ยนแปลง
- ปลอดภัย: OpenSploit ทำงานบนนักวิ่ง GitLab ของคุณ
ตั้งค่า
OpenSploit ทำงานในไปป์ไลน์ GitLab CI/CD ของคุณ นี่คือสิ่งที่คุณจะต้องตั้งค่า:
-
กำหนดค่าสภาพแวดล้อม GitLab ของคุณ
-
ตั้งค่า CI/CD
-
รับผู้ให้บริการโมเดล AI API คีย์
-
สร้างบัญชีบริการ
-
กำหนดค่าตัวแปร CI/CD
-
สร้างไฟล์กำหนดค่าโฟลว์ ต่อไปนี้เป็นตัวอย่าง:
Flow configuration
image: node:22-slimcommands:- echo "Installing opensploit"- npm install --global opensploit- 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 OpenSploit auth configuration"- mkdir --parents ~/.local/share/opensploit- |cat > ~/.local/share/opensploit/auth.json << EOF{"anthropic": {"type": "api","key": "$ANTHROPIC_API_KEY"}}EOF- echo "Configuring git"- git config --global user.email "opensploit@gitlab.com"- git config --global user.name "OpenSploit"- echo "Testing glab"- glab issue list- echo "Running OpenSploit"- |opensploit 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
ตัวอย่าง
นี่คือตัวอย่างบางส่วนของวิธีที่คุณสามารถใช้ OpenSploit ใน GitLab
-
อธิบายปัญหา
เพิ่มความคิดเห็นนี้ในปัญหา GitLab
@opensploit explain this issueOpenSploit จะอ่านปัญหาและตอบกลับพร้อมคำอธิบายที่ชัดเจน
-
แก้ไขปัญหา
ในปัญหา GitLab ให้พูดว่า:
@opensploit fix thisOpenSploit จะสร้างสาขาใหม่ ดำเนินการเปลี่ยนแปลง และเปิดคำขอรวมที่มีการเปลี่ยนแปลง
-
ตรวจสอบคำขอรวม
แสดงความคิดเห็นต่อไปนี้ในคำขอรวม GitLab
@opensploit review this merge requestOpenSploit จะตรวจสอบคำขอรวมและให้ข้อเสนอแนะ