erpnext/docs/JENKINS.md
Tyler Landes f57072667c Split Jenkins CI into visible stages for Coolify ERPNext validation.
Each check runs in its own pipeline stage (readiness, compose, image pull) so Jenkins shows clear pass/fail per section.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 18:43:02 -04:00

89 lines
3.2 KiB
Markdown

# Jenkins setup (Forgejo)
Repo: `https://git.aexoradao.com/epistemophiliac/erpnext.git`
Branch: `main`
Pipeline file: `Jenkinsfile` (repo root)
## Option A — Simple Pipeline (fastest)
If Multibranch shows an empty folder, use this instead.
1. **New Item****Pipeline** → name `erpnext`
2. **Pipeline** → Definition: **Pipeline script from SCM**
3. SCM: **Git**
- Repository URL: `https://git.aexoradao.com/epistemophiliac/erpnext.git`
- Credentials: Forgejo user + access token
- Branch: `*/main`
4. Script Path: `Jenkinsfile`
5. **Save****Build Now**
## Option B — Multibranch Pipeline
Indexing succeeds but the folder stays empty when **Discover branches** is missing.
1. **New Item****Multibranch Pipeline** → name `erpnext`
2. **Branch Sources****Git**
- URL + credentials (same as above)
3. **Behaviours****Add****Discover branches**
- Strategy: **All branches** (or include `main` via wildcard filter)
4. **Build Configuration**
- Mode: **by Jenkinsfile**
- Script Path: `Jenkinsfile`
5. **Save****Scan Repository Now**
You should see a `main` branch under the folder. Click it → **Build Now**.
### Optional: Forgejo webhook
Install the **Gitea** plugin in Jenkins, then use **Gitea** as the branch source (Forgejo-compatible) for automatic scans on push.
## Credentials
**Manage Jenkins → Credentials → Add**
- Kind: Username with password
- Username: `epistemophiliac`
- Password: Forgejo personal access token (repo read scope)
## Pipeline stages
| Stage | What it checks |
|-------|----------------|
| **Verify** | `Jenkinsfile`, `docker-compose.yml`, `example.env` present |
| **Production readiness** | `ci-readiness.sh` + `validate-docker-compose.sh` (Coolify rules, no secrets tracked) |
| **Bootstrap Docker tools** | Static `docker` + `docker-compose` in `.ci-bin/`, socket access |
| **Compose validate** | `docker compose config` on Coolify-stripped compose (no `exclude_from_hc`, no host ports) |
| **Verify ERPNext image** | `docker pull frappe/erpnext:<ERPNEXT_VERSION>` from `example.env` |
**Post-success:** archives `dist/docker-compose.coolify.yml` (the compose file Coolify actually parses).
This validates the repo before deploy; **Coolify deploy is separate** (set `DB_PASSWORD`, `SITE_NAME`, `ADMIN_PASSWORD`, domain on `frontend:8080`).
## Troubleshooting
### `fatal: not in a git directory` (branch indexing)
Usually a **corrupt Jenkins git cache** after changing container user. In the **jenkins** container terminal (Coolify):
```bash
rm -rf /var/jenkins_home/caches/git-*
chown -R jenkins:jenkins /var/jenkins_home
```
Then **Scan Repository Now** on the multibranch job.
### `permission denied` on `/var/run/docker.sock`
Jenkins must be in the host **docker** group. On the Coolify host:
```bash
stat -c '%g' /var/run/docker.sock
```
Set that number as `DOCKER_GID` on the **jenkins** Coolify service (was wrong at `999` on this host — use **`991`**), redeploy Jenkins, rebuild.
Do **not** run Jenkins as `user: 0:0` — it breaks `jenkins_home` ownership and git caches.
### Always use **Build Now** on `main`, not **Rebuild** on old builds
Old rebuilds replay old commits with old `Jenkinsfile` content.