GitLab
Brug OpenSploit i GitLab-problemer og Merge Requests.
OpenSploit integreres med din GitLab-arbejdsgang gennem din GitLab CI/CD-pipeline eller med GitLab Duo.
I begge tilfælde vil OpenSploit køre på dine GitLab-løbere.
GitLab CI
OpenSploit fungerer i en almindelig GitLab-pipeline. Du kan bygge det ind i en pipeline som en CI component
Her bruger vi en community-skabt CI/CD-komponent til OpenSploit — nagyv/gitlab-opensploit.
Funktioner
- Brug brugerdefineret konfiguration pr. job: Konfigurer OpenSploit med en brugerdefineret konfigurationsmappe, for eksempel
./config/#custom-directoryfor at aktivere eller deaktivere funktionalitet pr. OpenSploit påkald. - Minimal opsætning: CI-komponenten sætter OpenSploit op i baggrunden, du behøver kun at oprette OpenSploit-konfigurationen og den indledende prompt.
- Fleksibel: CI-komponenten understøtter flere input til at tilpasse dens adfærd
Opsætning
-
Gem din OpenSploit-autentificering JSON som en filtype CI-miljøvariabel under Indstillinger > CI/CD > Variabler. Sørg for at markere dem som “Maskede og skjulte”.
-
Tilføj følgende til din
.gitlab-ci.ymlfil..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"
For flere input og use cases check out the docs for denne komponent.
GitLab Duo
OpenSploit integreres med din GitLab-arbejdsgang.
Nævn @opensploit i en kommentar, og OpenSploit vil udføre opgaver i din GitLab CI-pipeline.
Funktioner
- Triageproblemer: Bed OpenSploit om at undersøge et problem og forklare dig det.
- Ret og implementer: Bed OpenSploit om at løse et problem eller implementere en funktion. Det vil oprette en ny branch og rejse en Merge Request med ændringer.
- Sikker: OpenSploit kører på dine GitLab-løbere.
Opsætning
OpenSploit kører i din GitLab CI/CD pipeline, her er hvad du skal bruge for at konfigurere det:
-
Konfigurer dit GitLab-miljø
-
Konfigurer CI/CD
-
Få en API-nøgle til en AI-modeludbyder
-
Opret en servicekonto
-
Konfigurer CI/CD variabler
-
Opret en flow-konfigurationsfil, her er et eksempel:
Flowkonfiguration
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
Du kan henvise til GitLab CLI agents docs for detaljerede instruktioner.
Eksempler
Her er nogle eksempler på, hvordan du kan bruge OpenSploit i GitLab.
-
Forklar et problem
Tilføj denne kommentar i et GitLab-problem.
@opensploit explain this issueOpenSploit vil læse spørgsmålet og svare med en klar forklaring.
-
Løs et problem
I et GitLab-nummer skal du sige:
@opensploit fix thisOpenSploit vil oprette en ny branch, implementere ændringer og åbne en Merge Request med ændringer.
-
Gennemgå Merge Requests
Efterlad følgende kommentar til en GitLab-Merge Request.
@opensploit review this merge requestOpenSploit vil gennemgå din Merge Request og give feedback.