|
| 1 | +# Jenkins CI/CD on Windows |
| 2 | + |
| 3 | +Deploy ONEVO to the Azure MVP VM from your local Windows PC using the root [`Jenkinsfile`](../Jenkinsfile) and [`scripts/deploy-vm.ps1`](../scripts/deploy-vm.ps1). |
| 4 | + |
| 5 | +## Why Jenkins here |
| 6 | + |
| 7 | +- Builds the **Windows connector installer** on the same machine (Inno Setup + PyInstaller). |
| 8 | +- SSH/SCP to the VM already works from your dev PC. |
| 9 | +- Avoids GitHub Actions secret/path drift while the pilot is active. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +1. [Jenkins LTS](https://www.jenkins.io/download/) installed on Windows. |
| 14 | +2. **Git** and **OpenSSH client** (Windows 10+ optional feature or Git for Windows). |
| 15 | +3. **.NET 8 SDK**, **Node.js 20**, **Python 3.11+** on the Jenkins agent (same PC). |
| 16 | +4. **Inno Setup 6** + PyInstaller deps for connector installer (see [`connector/installer/INSTALL.md`](../connector/installer/INSTALL.md)). |
| 17 | +5. SSH private key that can log in as `azureuser@20.193.69.220`. |
| 18 | + |
| 19 | +## Jenkins plugins |
| 20 | + |
| 21 | +- Pipeline |
| 22 | +- Git |
| 23 | +- Credentials Binding |
| 24 | +- SSH Agent (optional) |
| 25 | + |
| 26 | +## Credentials (Jenkins → Manage Credentials) |
| 27 | + |
| 28 | +| ID | Type | Value | |
| 29 | +|----|------|--------| |
| 30 | +| `onevo-vm-ssh-key` | SSH Username with private key | User `azureuser`, paste private key | |
| 31 | + |
| 32 | +## Create the pipeline job |
| 33 | + |
| 34 | +1. **New Item** → name `onevo-deploy` → **Pipeline**. |
| 35 | +2. **Pipeline** → Definition: **Pipeline script from SCM**. |
| 36 | +3. SCM: **Git**, repository URL, branch `azure-mvp-deploy` or `main`. |
| 37 | +4. Script Path: `Jenkinsfile`. |
| 38 | +5. Save → **Build with Parameters**. |
| 39 | + |
| 40 | +### Parameters (defaults) |
| 41 | + |
| 42 | +| Parameter | Default | |
| 43 | +|-----------|---------| |
| 44 | +| `VM_HOST` | `20.193.69.220` | |
| 45 | +| `VM_USER` | `azureuser` | |
| 46 | +| `BACKEND_URL` | `http://20.193.69.220:8081` | |
| 47 | +| `SKIP_INSTALLER` | false | |
| 48 | +| `SKIP_CI` | false | |
| 49 | +| `USE_GPU` | false (CPU VM) | |
| 50 | + |
| 51 | +## Manual deploy (without Jenkins) |
| 52 | + |
| 53 | +From repo root in PowerShell: |
| 54 | + |
| 55 | +```powershell |
| 56 | +powershell -ExecutionPolicy Bypass -File scripts/deploy-vm.ps1 ` |
| 57 | + -VmHost 20.193.69.220 ` |
| 58 | + -BackendUrl http://20.193.69.220:8081 |
| 59 | +``` |
| 60 | + |
| 61 | +Skip installer rebuild: |
| 62 | + |
| 63 | +```powershell |
| 64 | +powershell -ExecutionPolicy Bypass -File scripts/deploy-vm.ps1 -SkipInstaller |
| 65 | +``` |
| 66 | + |
| 67 | +## Auto-trigger on git push |
| 68 | + |
| 69 | +**Option A — Poll SCM** (simplest): In job config, **Build Triggers** → **Poll SCM** → `H/5 * * * *` (every 5 minutes). |
| 70 | + |
| 71 | +**Option B — GitHub webhook**: Install **GitHub plugin**, add webhook pointing to `http://<your-jenkins>:8080/github-webhook/`. |
| 72 | + |
| 73 | +## Pipeline stages |
| 74 | + |
| 75 | +1. **CI** — `dotnet build`, `npm run build`, `pytest` (parallel). |
| 76 | +2. **Deploy to VM** — tarball → SCP → extract under `/opt/onevo/app` → `docker compose build` + `up`. |
| 77 | +3. **Smoke test** — `GET /api/health` and dashboard HTTP 200. |
| 78 | + |
| 79 | +## VM layout (canonical) |
| 80 | + |
| 81 | +| Path | Purpose | |
| 82 | +|------|---------| |
| 83 | +| `/opt/onevo/app/` | Git repo + docker-compose project | |
| 84 | +| `/opt/onevo/app/.env` | Production secrets | |
| 85 | +| `/opt/onevo/app/installer-site/` | Connector EXE served by backend | |
| 86 | + |
| 87 | +## Troubleshooting |
| 88 | + |
| 89 | +| Issue | Fix | |
| 90 | +|-------|-----| |
| 91 | +| SSH permission denied | Check `onevo-vm-ssh-key` credential; test `ssh azureuser@20.193.69.220` from Jenkins service account | |
| 92 | +| GPU compose error | Keep `USE_GPU=false` on CPU VM | |
| 93 | +| Installer build fails | Install Inno Setup; run `scripts/build-installer.ps1` manually once | |
| 94 | +| Backend unhealthy after deploy | SSH to VM: `cd /opt/onevo/app && docker compose logs backend --tail 50` | |
| 95 | + |
| 96 | +## Related |
| 97 | + |
| 98 | +- [`docs/AZURE_MVP_DEPLOY.md`](AZURE_MVP_DEPLOY.md) — Azure + GitHub Actions |
| 99 | +- [`infra/mvp/deploy.sh`](../infra/mvp/deploy.sh) — VM-side deploy (ACR pull or local build) |
0 commit comments