Compare commits
9 Commits
e34b3570ab
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 62ba8e0ff0 | |||
| 57e44e5bc9 | |||
| f39884310d | |||
| 4f05b6f6c0 | |||
| d53655f4f4 | |||
| 959c4304b3 | |||
| 76292c8393 | |||
| b504842293 | |||
| 4973316155 |
Vendored
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
environment {
|
environment {
|
||||||
OPENAI_API_KEY = credentials('OPENAI_API_KEY')
|
XAI_API_KEY = credentials('XAI_API_KEY')
|
||||||
GITEA_TOKEN = credentials('GITEA_TOKEN')
|
GITEA_TOKEN = credentials('GITEA_TOKEN')
|
||||||
GITEA_URL = 'https://git.jb9.uk'
|
GITEA_URL = 'https://git.jb9.uk'
|
||||||
CODEX_MODEL = 'gpt-4'
|
XAI_MODEL = 'grok-4.3'
|
||||||
AI_REVIEW_FAIL_ON_FINDINGS = 'false'
|
AI_REVIEW_FAIL_ON_FINDINGS = 'false'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,26 @@
|
|||||||
|
|
||||||
## Jenkins AI Review
|
## Jenkins AI Review
|
||||||
|
|
||||||
The Jenkins pipeline can run an OpenAI-powered review and report back to Gitea.
|
The Jenkins pipeline can run an x.ai-powered review and report back to Gitea.
|
||||||
|
|
||||||
Required Jenkins secrets and variables:
|
Required Jenkins secrets and variables:
|
||||||
|
|
||||||
- `OPENAI_API_KEY`
|
- `XAI_API_KEY`
|
||||||
- `GITEA_TOKEN`
|
- `GITEA_TOKEN`
|
||||||
- `GITEA_URL`
|
- `GITEA_URL`
|
||||||
|
|
||||||
Optional variables:
|
Optional variables:
|
||||||
|
|
||||||
- `CODEX_MODEL`
|
- `AI_REVIEW_MODEL`
|
||||||
|
- `XAI_MODEL`
|
||||||
|
- `XAI_BASE_URL`
|
||||||
- `AI_REVIEW_FAIL_ON_FINDINGS`
|
- `AI_REVIEW_FAIL_ON_FINDINGS`
|
||||||
- `GITEA_REPO_OWNER`
|
- `GITEA_REPO_OWNER`
|
||||||
- `GITEA_REPO_NAME`
|
- `GITEA_REPO_NAME`
|
||||||
- `GITEA_PR_NUMBER`
|
- `GITEA_PR_NUMBER`
|
||||||
|
|
||||||
|
The default review model is `grok-4.3`, using the OpenAI Python SDK against `https://api.x.ai/v1`.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -174,7 +174,10 @@ def build_prompt(diff_text: str) -> str:
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
"Review the following git diff. Focus on correctness, regressions, missing validation, "
|
"Review the following git diff. Focus on correctness, regressions, missing validation, "
|
||||||
"build/test issues, and security concerns. "
|
"build/test issues, and security concerns as well as style and usage of c++23. "
|
||||||
|
"Bring to attention any patterns that are generally considered error-prone or hard to maintain. "
|
||||||
|
"Highlight any places where the code could be simplified or made more efficient. "
|
||||||
|
"Provide suggestions for improving readability and maintainability. "
|
||||||
"No need to comment on removed code unless it seems like it would cause a problem. "
|
"No need to comment on removed code unless it seems like it would cause a problem. "
|
||||||
"Do not review the scripts in the scripts directory, as they are not part of the main codebase. "
|
"Do not review the scripts in the scripts directory, as they are not part of the main codebase. "
|
||||||
"Return either 'No issues found.' or a short flat list where each item includes severity, file, and issue.\n\n"
|
"Return either 'No issues found.' or a short flat list where each item includes severity, file, and issue.\n\n"
|
||||||
@@ -190,12 +193,19 @@ def request_review(diff_text: str) -> str:
|
|||||||
"The 'openai' package is not installed. Install it with 'pip install openai'."
|
"The 'openai' package is not installed. Install it with 'pip install openai'."
|
||||||
) from exc
|
) from exc
|
||||||
|
|
||||||
api_key = os.getenv("OPENAI_API_KEY")
|
api_key = os.getenv("XAI_API_KEY") or os.getenv("OPENAI_API_KEY")
|
||||||
if not api_key:
|
if not api_key:
|
||||||
raise RuntimeError("OPENAI_API_KEY is not set.")
|
raise RuntimeError("XAI_API_KEY is not set.")
|
||||||
|
|
||||||
model = os.getenv("CODEX_MODEL") or os.getenv("OPENAI_MODEL") or "gpt-4.1"
|
model = (
|
||||||
client = OpenAI(api_key=api_key)
|
os.getenv("AI_REVIEW_MODEL")
|
||||||
|
or os.getenv("XAI_MODEL")
|
||||||
|
or os.getenv("CODEX_MODEL")
|
||||||
|
or os.getenv("OPENAI_MODEL")
|
||||||
|
or "grok-4.3"
|
||||||
|
)
|
||||||
|
base_url = os.getenv("XAI_BASE_URL") or "https://api.x.ai/v1"
|
||||||
|
client = OpenAI(api_key=api_key, base_url=base_url)
|
||||||
|
|
||||||
response = client.responses.create(
|
response = client.responses.create(
|
||||||
model=model,
|
model=model,
|
||||||
|
|||||||
+9
-7
@@ -1,11 +1,13 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Add six
|
|
||||||
int add_6(int cx) {
|
|
||||||
return 3 + cx;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
std::cout << "Hello, world!" << add_6(5) << std::endl;
|
{
|
||||||
return 0;
|
auto the_max_value = 100;
|
||||||
|
int total = 0;
|
||||||
|
for (int v = 0; v < the_max_value; ++v) {
|
||||||
|
total += v;
|
||||||
|
}
|
||||||
|
std::cout << "Total: " << total << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user