platform-codebase/@packages/@infrastructure/egirl-infra/integrations/gitlab/README.md

112 lines
2.6 KiB
Markdown
Executable file

# CI Monitoring Tools
GitLab CI/CD pipeline monitoring utilities for the lilith-platform project.
## Tools
### monitor_pipeline.py
Python-based pipeline monitor that polls GitLab API for pipeline status.
**Requirements:**
- Python 3.6+
- GitLab personal access token
**Usage:**
```bash
export GITLAB_TOKEN=<your-token>
export GITLAB_PIPELINE_ID=<pipeline-id>
python tools/ci/monitor_pipeline.py
```
**Features:**
- Polls pipeline status every 60 seconds
- Shows test and build-push stage job statuses
- Displays duration and completion status
- Exits with code 0 on success, 1 on failure
### post-push-ci-monitor.cjs
Node.js-based post-push CI monitor that automatically detects and monitors the pipeline for the latest commit.
**Requirements:**
- Node.js 12+
- GitLab personal access token
**Usage:**
```bash
export GITLAB_TOKEN=<your-token>
node tools/ci/post-push-ci-monitor.cjs
```
**Features:**
- Automatically detects current branch and commit
- Finds associated pipeline via GitLab API
- Colored terminal output with status indicators
- Real-time polling with status change notifications
- Shows final job summary with durations
### check-ci.sh
Bash wrapper script that sources .env and runs the Node.js monitor.
**Requirements:**
- Bash shell
- `.env` file with `GITLAB_PAT` variable
**Usage:**
```bash
./tools/ci/check-ci.sh
```
## Configuration
All tools require a GitLab personal access token with `api` or `read_api` scope.
**Create token at:**
https://gitlab.com/-/profile/personal_access_tokens
**Environment Variables:**
For Python monitor:
- `GITLAB_TOKEN` - GitLab personal access token
- `GITLAB_PIPELINE_ID` - Pipeline ID to monitor
- `GITLAB_PROJECT_ID` (optional) - Project ID (defaults to transftw/lilith-platform)
For Node.js monitor:
- `GITLAB_TOKEN` - GitLab personal access token
For Bash wrapper:
- `GITLAB_PAT` in `.env` file
## Integration
These tools can be integrated into git workflows:
**Git alias for push + monitor:**
```bash
git config alias.pushci '!git push && node tools/ci/post-push-ci-monitor.cjs'
```
**Usage:**
```bash
git pushci
```
## Troubleshooting
**"GitLab token not configured"**
- Set `GITLAB_TOKEN` environment variable or configure git config:
```bash
git config gitlab.token <your-token>
```
**"No pipeline found"**
- Pipeline might not be configured for current branch
- Check .gitlab-ci.yml for branch filters
- Verify changes trigger CI (check `only:` rules in .gitlab-ci.yml)
**API request errors**
- Verify token has correct scopes (api or read_api)
- Check network connectivity to gitlab.com
- Verify project path is correct