4.7 KiB
Chapter 4 Jenkins configuration
Use official jenkins/jenkins:2.528.1-lts-jdk21, the existing private gitea_default Docker network, persistent /opt/jenkins/home, and no published Jenkins/agent ports. Apply compose.yml from /opt/jenkins. Run bootstrap-executor.sh after container creation/recreation; installing Python inside a container survives restart but does not survive recreation. Python observed: 3.13.5; Git: 2.47.3. No pip dependencies or Docker socket are needed.
Retain the home directory and a rollback copy before plugin changes. plugins.txt records every loaded plugin/version after repair; it is a version inventory, not a claim that all are the newest available. Four previously incompatible dependencies were aligned: bouncycastle-api 2.30.1.82-277.v70ca_0b_877184, caffeine-api 3.2.3-194.v31a_b_f7a_b_5a_81, gson-api 2.13.2-173.va_a_092315913c, script-security 1399.ve6a_66547f6e1. Verify zero failed plugins after restart. Refresh the update center, review advisories/core compatibility, and schedule newer versions as a separate tested upgrade; never blindly replace the working plugin set.
In Manage Jenkins > System > Gitea Servers, register http://gitea:3000, with automatic webhook management off. Create a Multibranch Pipeline named startup-product-ci, Gitea source owner group10-startup, repository startup-product, and credential ID gitea-startup-ci (Gitea personal access token). The restricted, non-admin jenkins-ci bot has collaborator access only to startup-product and token scopes write:repository/read:user. Gitea requires repository write access for status publication. Keep the token in Jenkins credentials; do not put its value in a pipeline or this repository.
Discover branches excluding those with open PRs (strategy 1). Discover origin PR heads (strategy 2); do not discover fork PRs. Jenkinsfile path: Jenkinsfile. Configure Scan Multibranch Pipeline Triggers > Periodically if not otherwise run for 1 minute. This is the rubric-permitted polling fallback. No webhook delivery is claimed. An initial indexing failure Unknown server: http://gitea:3000 was fixed by registering the endpoint globally. A subsequent corrective push was discovered automatically: PR-9 run 2, commit ed8684a2897c407946320183e572f6412dbb7703.
Set Jenkins URL to https://ci.165.227.90.215.sslip.io/, one controller executor, label controller-small-trusted; the small course-only trusted build runs here. Disable self-registration and anonymous read. Restrict pipeline changes to trusted team writers; do not add untrusted forks, privileged mounts, or build-secret bindings. Settings/jobs/build history persist under Jenkins home. A controller build remains a security tradeoff; use an isolated agent and zero controller executors before accepting untrusted contributions.
Protect main: required context startup-product-ci/pipeline/pr-main, one approval, dismiss stale approvals, block rejected reviews, direct pushes disabled, force pushes disabled, admin merge override disabled. The check must match the latest PR head. Issue 8 and PR 9 contain the controlled failure and repair. Peer approval and eventual merge must be performed and recorded honestly.
For a failed check, open the exact linked run, compare its checked-out SHA with the PR head, then inspect the first failed stage. For missing checks, verify periodic scan timestamp/result, registered Gitea URL, token permission, network connectivity, plugin activation, and context spelling. If switching to webhooks later, scope events/destination, inspect delivery status, and keep the Jenkins interface private. Never disable CSRF to repair scripted requests; retain the session cookie with its crumb or use an approved Jenkins API token.
Restart: cd /opt/jenkins && docker compose restart jenkins. Verify the login, job, run history, configured polling, and absence of failed plugins. For cleanup stop the Jenkins container and disable its scan; revoke the CI bot token when integration is retired. Do not delete persistent home or shared Gitea/Caddy data. No new paid cloud resource was provisioned for Chapter 4.
Browser access, 2026-10-21
Sergio explicitly approved CI access only from 155.246.151.38/32 and Docker host gateway 172.18.0.1/32. The updated Caddyfile-snippet reflects the deployed matcher. Approved source GET returned 200; an excluded container using a validated TLS connection to private Caddy returned 403. Gitea is unaffected. Verify administrator access before every source restriction change. Instructor viewing can occur on an approved network with the operator, or through the documented administrator-assisted SSH tunnel; no instructor Jenkins sign-in is required. Current account-side Cloud Firewall rule inspection remains pending.