Skip to content

Commit e01e01a

Browse files
committed
Use $GITLAB_PERSONAL_ACCESS_TOKEN in check-ci-jobs
1 parent 0c09f3c commit e01e01a

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

appsec/helper-rust/CLAUDE.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,8 @@ The appsec child pipeline IID can be found in the parent pipeline's downstream p
318318
The GitLab MCP tools don't include a job trace/log reader. To read job logs via the API:
319319

320320
```bash
321-
# Extract the token from MCP config (project ID 355 = DataDog/apm-reliability/dd-trace-php)
322-
jq -r '.mcpServers.gitlab.env.GITLAB_PERSONAL_ACCESS_TOKEN' ~/.claude.json
323-
324-
# Then fetch job trace using the token
325-
curl -s -H "PRIVATE-TOKEN: <TOKEN>" "https://gitlab.ddbuild.io/api/v4/projects/355/jobs/<JOB_ID>/trace" > /tmp/...
321+
# project ID 355 = DataDog/apm-reliability/dd-trace-php
322+
curl -s -H "PRIVATE-TOKEN: $GITLAB_PERSONAL_ACCESS_TOKEN" "https://gitlab.ddbuild.io/api/v4/projects/355/jobs/<JOB_ID>/trace" > /tmp/...
326323
```
327324

328325
### Monitoring CI Jobs

appsec/helper-rust/scripts/check-ci-jobs.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"""
1414

1515
import argparse
16-
import json
1716
import os
1817
import subprocess
1918
import sys
@@ -50,18 +49,12 @@
5049

5150

5251
def get_token() -> str:
53-
config_path = Path.home() / ".claude.json"
54-
config = json.loads(config_path.read_text())
55-
token = (
56-
config.get("mcpServers", {})
57-
.get("gitlab", {})
58-
.get("env", {})
59-
.get("GITLAB_PERSONAL_ACCESS_TOKEN")
60-
)
61-
if not token or token == "null":
62-
print("ERROR: Could not extract GitLab token from ~/.claude.json", file=sys.stderr)
63-
sys.exit(1)
64-
return token
52+
token = os.environ.get("GITLAB_PERSONAL_ACCESS_TOKEN")
53+
if token and token != "null":
54+
return token
55+
56+
print("ERROR: GITLAB_PERSONAL_ACCESS_TOKEN is not set", file=sys.stderr)
57+
sys.exit(1)
6558

6659

6760
def api_get(token: str, path: str, params: dict | None = None) -> list | dict:

0 commit comments

Comments
 (0)