Document Assignment 6 Jenkins CI in the manual #16
@@ -0,0 +1,202 @@
|
|||||||
|
# Jenkins plugin and pipeline capacity experiment
|
||||||
|
|
||||||
|
Prepared for Vincent Sun and Billy Ye on October 21, 2026. This disposable test
|
||||||
|
passed locally in Docker Desktop; it has NOT run on The-Ocean and is not the
|
||||||
|
Assignment 6 deployment. See `VALIDATION.md` for the evidence and limitations.
|
||||||
|
|
||||||
|
## The question we are answering
|
||||||
|
|
||||||
|
Can The-Ocean's existing 512 MB plan run the Jenkins features we need, together
|
||||||
|
with Gitea, under the limits used in the earlier core-only experiment?
|
||||||
|
|
||||||
|
Jenkins core is the base server. Plugins add features to it. Pipeline supplies
|
||||||
|
the job execution engine and steps; the Gitea connector supplies integration
|
||||||
|
with Gitea. A plugin can download successfully but fail to load because of
|
||||||
|
incompatible dependencies or insufficient memory. Loading successfully also
|
||||||
|
does not prove that a build can run. We check these separately.
|
||||||
|
|
||||||
|
The previous core-only experiment started Jenkins, but its final accounting
|
||||||
|
included about 212 MiB swap as well as 80 MiB RAM. Its raw 60-second PASS was
|
||||||
|
qualified because the successful HTTP samples spanned only 54 seconds.
|
||||||
|
|
||||||
|
## What, why and how
|
||||||
|
|
||||||
|
| Check | Why it matters | How we test / pass criterion |
|
||||||
|
|---|---|---|
|
||||||
|
| Fresh baseline | Yesterday's resources may differ today | Correct hostname/root session, available RAM >=128 MiB, swap free >=512 MiB, enough Docker disk, unused test port, Gitea HTTP 200 |
|
||||||
|
| Prepare plugins on the laptop | Catalog processing exceeded the old 128 MiB installer heap locally | Official installer resolves the selected plugins in a separate laptop container with 768 MiB RAM / 512 MiB heap; exact roots, all resolved versions and archive hashes recorded |
|
||||||
|
| Tools and plugin installation on the target | The useful system needs more than Jenkins core | In a fresh capped container, install Python/Git and copy the verified prepared archives; inspect the installed versions before Jenkins starts |
|
||||||
|
| Plugin loading | Files on disk are not evidence that Jenkins loaded them | After initialization, verify requested plugins at expected versions, every installed plugin active and no failed-plugin entries |
|
||||||
|
| Healthy idle | A momentary login response is too weak | HTTP `/login` returns 200 over >=60 seconds of sampled observations AFTER initialization and plugin verification; any failed probe resets the clock |
|
||||||
|
| Passing pipeline | Exercise actual execution and unit tests | One executor runs dependency checks, a fresh local fixture, Python syntax checking and two unit tests; Jenkins reports SUCCESS |
|
||||||
|
| Controlled failure | Prove the tests actually detect a defect | Change multiplication to addition only in the disposable workspace; Jenkins reports FAILURE and console proves the intended `13 != 30` assertion, not an unrelated infrastructure error |
|
||||||
|
| Repair | Prove recovery works without restarting the service | Recreate the original fixture in a fresh workspace on the same job; the two tests run and Jenkins reports SUCCESS |
|
||||||
|
| Shared-host protection | Jenkins must not consume all the host's resources | Repeatedly check host available RAM/free swap, Gitea HTTP 200, container RAM/swap, CPU throttling and OOM counters; abort on guard failure |
|
||||||
|
| Cleanup | Leave existing coursework services intact | Remove only this owner-labelled test container and its anonymous home volume; preserve evidence and the base image; check Gitea afterward |
|
||||||
|
|
||||||
|
This is a small selected plugin set, not the smallest theoretically possible
|
||||||
|
dependency graph. `workflow-aggregator` is a suite, so two requested IDs will
|
||||||
|
produce more than two installed plugins. The current root requests are:
|
||||||
|
|
||||||
|
```text
|
||||||
|
workflow-aggregator:608.v67378e9d3db_1
|
||||||
|
gitea:286.v0740a_413c1eb_
|
||||||
|
```
|
||||||
|
|
||||||
|
The prepared local bundle contains 59 plugin archives (45,336,313 bytes). Two
|
||||||
|
requested features therefore do not mean two loaded files. The official plugin
|
||||||
|
pages checked October 21 list minimum Jenkins versions
|
||||||
|
2.479.3 and 2.528.3 respectively, below the recorded 2.580.1 core. That baseline
|
||||||
|
comparison is only a preliminary check; dependency resolution and actual loading
|
||||||
|
are still tested. Laptop preparation uses the official bundled `jenkins-plugin-cli`.
|
||||||
|
Current dependencies are resolved (`--latest true`) rather than deliberately
|
||||||
|
installing the old aggregator's minimum dependency versions. Requested roots
|
||||||
|
are checked for an exact match; every resolved archive version and SHA-256 goes
|
||||||
|
into the prepared `manifest.json`, with a full `plugins.lock` beside it. The
|
||||||
|
target verifies the hashes before starting Docker, then inventories the copied
|
||||||
|
archives again as `plugins-resolved.json` / `plugins-resolved.lock`.
|
||||||
|
Keep installer security warnings visible in prepared `installer.txt` and review them before
|
||||||
|
any real deployment. No flag hides warnings or skips failed plugins.
|
||||||
|
|
||||||
|
New dependency preparation and Debian package versions can change between runs.
|
||||||
|
Reusing the SAME prepared bundle fixes the plugin archives and hashes for the
|
||||||
|
target comparison; Python/Git apt versions remain recorded, not fully locked.
|
||||||
|
Retain the lock file/hashes and package-version output. Do not silently
|
||||||
|
substitute a different image/plugin set and compare it as the same experiment.
|
||||||
|
|
||||||
|
## Isolation and resource limits
|
||||||
|
|
||||||
|
- Same official core image tag as before, now also pinned to its recorded digest:
|
||||||
|
`jenkins/jenkins:2.580.1-jdk21@sha256:a660310e39ade10631f774bacd5219de767dfd08947ea5c32a739b5e5bb382c1`.
|
||||||
|
- 256 MiB container RAM; 512 MiB combined RAM plus swap, allowing up to 256 MiB
|
||||||
|
container swap. Half one CPU, 256 processes, Java heap 32-128 MiB and Serial GC.
|
||||||
|
- These target limits cover Python/Git installation, copying the prepared
|
||||||
|
plugins, AND Jenkins/Python pipeline runtime. Plugin catalog resolution and
|
||||||
|
downloads are a SEPARATE laptop-only preparation: 768 MiB RAM, 1 GiB combined
|
||||||
|
RAM+swap, 512 MiB Java heap, one CPU, no service port, fifteen-minute timeout.
|
||||||
|
Those preparation limits are not proposed for the 512 MB droplet. The base-image
|
||||||
|
pull is also separate, reused if cached, and bounded to five minutes.
|
||||||
|
- Existing host swap, packages, proxy, firewall, Gitea data and containers are
|
||||||
|
not changed. The installer runs as root inside the temporary container only;
|
||||||
|
the Jenkins process and its builds then run as the container's `jenkins` user.
|
||||||
|
- Only this source directory and the prepared plugin directory are mounted,
|
||||||
|
both read-only. No Docker socket, real
|
||||||
|
credential, runner registration, production checkout or existing Jenkins home.
|
||||||
|
- Only `127.0.0.1:18080` is published. Nothing is attached to Caddy or a public
|
||||||
|
Jenkins hostname. The disposable instance has authentication enabled and
|
||||||
|
anonymous read disabled. Its random test-account password is generated inside
|
||||||
|
Jenkins, never printed/read/exported, and discarded with the temporary home.
|
||||||
|
Setup-wizard automation is specific to this disposable instance.
|
||||||
|
- One built-in executor runs only this reviewed local fixture. This is an explicit
|
||||||
|
capacity-test choice, not approval to run arbitrary PR code on a production
|
||||||
|
controller. No separate agent is tested here.
|
||||||
|
- A sampled host floor of 48 MiB available RAM or 128 MiB free swap aborts the
|
||||||
|
run; any sampled Gitea non-200, container OOM event or unexpected exit also
|
||||||
|
aborts. These are sampled best-effort guards, not a guarantee that Gitea can
|
||||||
|
never be affected between probes. A failed health request alone does not
|
||||||
|
establish that Jenkins caused the failure.
|
||||||
|
- Installation timeout: 20 minutes. Startup/idle timeout: 15 minutes. Pipeline
|
||||||
|
phase: 10 minutes; each build has a three-minute outer wait. Overall: 45 minutes.
|
||||||
|
A detached watchdog attempts targeted cleanup after 46 minutes if SSH drops.
|
||||||
|
Normal interruption also runs cleanup. Check `cleanup_ok` and inspect leftovers
|
||||||
|
after machine/Docker failure; no script can guarantee cleanup of a stopped host.
|
||||||
|
- Requires Linux cgroup v2, Docker, Python 3.8+ on the HOST and root on The-Ocean.
|
||||||
|
Ubuntu 24.04 normally provides Python, but the preflight must confirm it.
|
||||||
|
|
||||||
|
The explicit Windows `--local-smoke-test` mode applies the same CONTAINER runtime
|
||||||
|
limits but does not run the droplet host RAM/swap/disk guards or Gitea checks.
|
||||||
|
Those fields are recorded as null, not invented measurements. Docker Desktop's
|
||||||
|
VM has different resources and does not host the real Gitea service, so local
|
||||||
|
success does not answer whether Jenkins and Gitea can share the droplet.
|
||||||
|
|
||||||
|
The experiment adds no cloud instance, subscription or resize. It uses the team's
|
||||||
|
existing droplet, disk and ordinary package/plugin/image download traffic; provider
|
||||||
|
transfer billing, if applicable, remains subject to the existing account plan.
|
||||||
|
Vincent/Billy own execution and cleanup. No maintenance/reboot is performed.
|
||||||
|
|
||||||
|
## Run when SSH access is restored
|
||||||
|
|
||||||
|
For the local regression checks only, run `python ci/jenkins-capacity/test_harness.py`
|
||||||
|
from the repository on Windows, or use `python3` on Linux. These standard-library
|
||||||
|
tests need no Docker or cloud access and do not launch Jenkins. They cannot
|
||||||
|
replace the real experiment below.
|
||||||
|
|
||||||
|
First collect/review the baseline as discussed. This script intentionally refuses
|
||||||
|
the `--run-on-the-ocean` option on Vincent's laptop or a differently named host.
|
||||||
|
Do not change that guard to obtain a false droplet PASS. Docker Desktop is not
|
||||||
|
needed to upload/run the PREPARED package; Docker on the droplet is needed.
|
||||||
|
|
||||||
|
Use the prepared ZIP, which includes a `jenkins-capacity` directory with its
|
||||||
|
`prepared-plugins` subdirectory. Extract it to a new task-local folder. From
|
||||||
|
**PowerShell in the extracted ZIP's parent folder**:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
scp -i "$env:USERPROFILE\.ssh\digitalocean" -r .\jenkins-capacity root@147.182.178.136:/root/ssw590-plugin-test
|
||||||
|
ssh -i "$env:USERPROFILE\.ssh\digitalocean" root@147.182.178.136
|
||||||
|
```
|
||||||
|
|
||||||
|
The SCP command assumes `/root/ssw590-plugin-test` does not already exist. If it
|
||||||
|
does, inspect its contents before copying; SCP may nest the source directory.
|
||||||
|
Upload the whole directory, not only `run_test.py`. Billy uses his own trusted
|
||||||
|
SSH key, not Vincent's key path.
|
||||||
|
|
||||||
|
Then **inside the droplet's Linux terminal**:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd /root/ssw590-plugin-test
|
||||||
|
python3 --version
|
||||||
|
python3 run_test.py --help
|
||||||
|
python3 run_test.py --run-on-the-ocean
|
||||||
|
```
|
||||||
|
|
||||||
|
Expect progress lines naming `tools`, `plugins`, `startup/ready`, and
|
||||||
|
`startup/pipelines`, followed by `result.json` and the evidence path. During
|
||||||
|
installation, Jenkins HTTP is reported as 0 because Jenkins has not started;
|
||||||
|
Gitea should remain 200. You can stop with Ctrl+C; let cleanup finish.
|
||||||
|
|
||||||
|
Evidence goes under `/root/ssw590-capacity-evidence/plugins-<UTC>-<PID>/`.
|
||||||
|
Download that exact printed directory with SCP for review. It contains baseline,
|
||||||
|
input hashes, base-image identity, resource samples, checkpoint duration, resolved
|
||||||
|
plugins, controlled build logs, final state and result. It deliberately excludes
|
||||||
|
raw Jenkins controller logs, the credential-bearing home and private keys.
|
||||||
|
|
||||||
|
For a NEW bundle from source on Windows (not needed to use the packaged one):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python ci/jenkins-capacity/prepare_plugins.py --output build/jenkins-plugin-bundle
|
||||||
|
python ci/jenkins-capacity/run_test.py --local-smoke-test --plugin-bundle build/jenkins-plugin-bundle
|
||||||
|
```
|
||||||
|
|
||||||
|
The preparation command refuses to overwrite an existing bundle. Preserve or
|
||||||
|
review the old bundle first. In the repository the archives live under ignored
|
||||||
|
`build/`; they are packaged into `prepared-plugins` for upload, not committed.
|
||||||
|
|
||||||
|
Interpret the result by phase. Preparation failure can be a download, dependency,
|
||||||
|
disk or memory problem; it does not automatically mean Jenkins cannot run.
|
||||||
|
Target installation failure may come from apt/tools or copying/unpacking plugins.
|
||||||
|
Startup failure can be plugin compatibility or resource pressure. An intentional
|
||||||
|
fixture FAILURE is expected only if the correct unit-test assertion is present.
|
||||||
|
Check OOM/CPU/swap and installer output before attributing a cause. A PASS with
|
||||||
|
heavy swap or throttling demonstrates feasibility under this small test, not
|
||||||
|
comfortable capacity, long-term reliability, concurrency or production readiness.
|
||||||
|
|
||||||
|
## What a PASS does not prove
|
||||||
|
|
||||||
|
The Gitea plugin must load here, but this experiment does not configure or exercise
|
||||||
|
Gitea discovery, SCM checkout, PR head selection, webhooks, credentials, status
|
||||||
|
reporting or branch protection. Git is installed and its version checked; no
|
||||||
|
repository is cloned. The pipeline is the bundled local fixture, not yet the
|
||||||
|
assignment's root repository Jenkinsfile. The fixture's repair is not a real
|
||||||
|
issue-linked reviewed PR. No HTTPS deployment, restart persistence, real admin
|
||||||
|
accounts, concurrent runner test, final report chapter or assignment completion
|
||||||
|
is claimed. Those are subsequent implementation/evidence steps.
|
||||||
|
|
||||||
|
## Primary references
|
||||||
|
|
||||||
|
- [Official Jenkins Docker image and plugin customization](https://github.com/jenkinsci/docker)
|
||||||
|
- [Plugin installation manager options and dependency behavior](https://github.com/jenkinsci/plugin-installation-manager-tool)
|
||||||
|
- [Pipeline suite](https://plugins.jenkins.io/workflow-aggregator/)
|
||||||
|
- [Gitea connector](https://plugins.jenkins.io/gitea/)
|
||||||
|
- [Groovy initialization hooks](https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/)
|
||||||
|
- [Controller isolation and built-in executor risks](https://www.jenkins.io/doc/book/security/controller-isolation/)
|
||||||
|
- [Docker RAM, swap and CPU constraints](https://docs.docker.com/engine/containers/resource_constraints/)
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# Verification, October 21, 2026
|
||||||
|
|
||||||
|
**Prepared and passed in Windows Docker Desktop. NOT run on The-Ocean.**
|
||||||
|
|
||||||
|
## Actual Docker results
|
||||||
|
|
||||||
|
1. Initial all-in-one local attempt, `plugins-20261021T232534Z-28212`: Python/Git
|
||||||
|
installation succeeded, but `jenkins-plugin-cli` failed with Java heap space
|
||||||
|
exhaustion while fetching the plugin-version catalog at the original 128 MiB
|
||||||
|
heap. Container exit code was 1; Docker `OOMKilled` was false. This was a JVM
|
||||||
|
heap failure, not a kernel container kill and not a Jenkins runtime test.
|
||||||
|
Cleanup succeeded. Original installer output/result were preserved.
|
||||||
|
2. Separate local plugin preparation: official installer, 768 MiB container RAM,
|
||||||
|
1 GiB combined RAM+swap, 512 MiB Java heap, one CPU. Successfully resolved 59
|
||||||
|
archives totaling 45,336,313 bytes, with exact requested root versions and a
|
||||||
|
SHA-256/version manifest. The preparation container was removed. This proves
|
||||||
|
that these preparation bounds worked, not the minimum memory the installer
|
||||||
|
needs. It did not start Jenkins.
|
||||||
|
3. Revised runtime test, `plugins-20261021T233125Z-27744`: SAME original runtime
|
||||||
|
limits (256 MiB RAM, 512 MiB combined RAM+swap, half a CPU, 128 MiB Java heap).
|
||||||
|
All 59 plugins were active, no failed plugins were reported, and healthy HTTP
|
||||||
|
samples spanned **65.39 seconds** before jobs started. Build 1 was SUCCESS;
|
||||||
|
build 2 was FAILURE with the intended `13 != 30` assertion and two unit tests
|
||||||
|
executed; build 3 repaired the calculation and was SUCCESS. Final result PASS,
|
||||||
|
cleanup true. A subsequent owner-label query found no experiment containers.
|
||||||
|
|
||||||
|
Twenty runtime samples recorded peak cgroup RAM 255.99 MiB, peak swap 137.63 MiB,
|
||||||
|
and peak SIMULTANEOUS RAM+swap 389.51 MiB. The maxima of RAM and swap need not occur
|
||||||
|
at the same time. Container OOM/OOM-kill events were zero; the RAM cap was reached
|
||||||
|
repeatedly and CPU throttling occurred. These results demonstrate this small
|
||||||
|
runtime exercise on the laptop, not spare capacity or concurrent Gitea safety.
|
||||||
|
|
||||||
|
Docker Desktop reported 16 CPUs and about 13.5 GiB VM memory. Local mode deliberately
|
||||||
|
did not measure the droplet's host memory, swap, disk or Gitea health: those fields
|
||||||
|
are null. The real droplet has about 458 MiB RAM and runs Gitea/Caddy. Its guarded
|
||||||
|
run remains necessary. No new cloud resource, firewall change or reboot occurred.
|
||||||
|
|
||||||
|
Raw local evidence remains under ignored `build/evidence/jenkins-plugin-local/`;
|
||||||
|
prepared binaries/manifest are under ignored `build/jenkins-plugin-bundle/`.
|
||||||
|
The shareable ZIP includes the prepared archives and selected non-secret local
|
||||||
|
evidence. No controller logs, Jenkins home, token, SSH key or generated test
|
||||||
|
password is included. The official base image is cached for reuse; the temporary
|
||||||
|
containers and anonymous homes were removed.
|
||||||
|
|
||||||
|
## Local regression and static checks
|
||||||
|
|
||||||
|
- Nine Python regression/fault checks passed: the previous 54-second false PASS,
|
||||||
|
failed-probe timer reset, monitor's complete idle gate, low memory/swap aborts,
|
||||||
|
refusal to delete another owner's container, cleanup despite diagnostic errors,
|
||||||
|
separate cgroup accounting, folded plugin manifests/exact root versions, and
|
||||||
|
actual Python fixture pass/failure/repair.
|
||||||
|
- Bash bootstrap syntax was checked and actual Docker execution succeeded.
|
||||||
|
- Opted-in droplet execution on Windows was rejected before Docker activity;
|
||||||
|
the container bootstrap also refused execution outside its test container.
|
||||||
|
- Python sources parsed and Linux inputs used LF endings.
|
||||||
|
- Plugin root versions/minimum core baselines were checked against official
|
||||||
|
Jenkins pages. Actual installation and activation supplied stronger evidence.
|
||||||
|
|
||||||
|
## Still unverified
|
||||||
|
|
||||||
|
- Droplet capacity with Gitea/Caddy, host pressure guards, site checks, target apt
|
||||||
|
availability and cleanup/watchdog behavior after a real SSH disconnect.
|
||||||
|
- Gitea discovery/SCM checkout/PR revision selection/webhooks/status reporting,
|
||||||
|
merge protection, a production build boundary, HTTPS deployment and persistence.
|
||||||
|
- The real reviewed failure/repair PR and Assignment 6 report chapter/submission.
|
||||||
|
|
||||||
|
SSH and the web console time out from school. The attached Cloud Firewall visibly
|
||||||
|
allowed the measured school IPv4; Gitea HTTPS returned 200 while direct TCP 22
|
||||||
|
timed out. This does not establish where filtering occurs. Docker was initially
|
||||||
|
off, then Vincent enabled it and authorized using it for local verification.
|
||||||
|
|
||||||
|
This directory supplements the earlier October 21 Billy/Claude handoff, which
|
||||||
|
predates this new test and manual record. No commit or push was performed.
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Runs INSIDE the newly created disposable container, never on the host.
|
||||||
|
set -euo pipefail
|
||||||
|
[ "${SSW590_DISPOSABLE_TEST:-}" = 1 ] && [ -f /.dockerenv ] && [ -d /opt/ssw590-input ] || {
|
||||||
|
echo 'Refusing: this bootstrap runs only inside the disposable test container.' >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
umask 022
|
||||||
|
mkdir -p /tmp/ssw590
|
||||||
|
chmod 755 /tmp/ssw590
|
||||||
|
echo tools > /tmp/ssw590/phase
|
||||||
|
{
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update
|
||||||
|
apt-get install --no-install-recommends -y python3 git util-linux
|
||||||
|
apt-get clean
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
python3 --version
|
||||||
|
git --version
|
||||||
|
echo plugins > /tmp/ssw590/phase
|
||||||
|
mkdir -p /usr/share/jenkins/ref/plugins /usr/share/jenkins/ref/init.groovy.d
|
||||||
|
chown jenkins:jenkins /usr/share/jenkins/ref/plugins
|
||||||
|
# Catalog resolution is prepared on the laptop, outside the runtime limits.
|
||||||
|
# The host verifies this bundle's hashes before mounting it read-only.
|
||||||
|
cp /opt/ssw590-plugins/*.jpi /usr/share/jenkins/ref/plugins/
|
||||||
|
chown -R jenkins:jenkins /usr/share/jenkins/ref/plugins
|
||||||
|
python3 /opt/ssw590-input/inventory.py /usr/share/jenkins/ref/plugins \
|
||||||
|
/opt/ssw590-input/plugins.txt > /tmp/ssw590/plugins-resolved.json
|
||||||
|
python3 - <<'PY' > /tmp/ssw590/plugins-resolved.lock
|
||||||
|
import json
|
||||||
|
for p in json.load(open('/tmp/ssw590/plugins-resolved.json')):
|
||||||
|
print(p['id'] + ':' + p['version'])
|
||||||
|
PY
|
||||||
|
cp /opt/ssw590-input/init.groovy /usr/share/jenkins/ref/init.groovy.d/90-capacity.groovy
|
||||||
|
chown -R jenkins:jenkins /tmp/ssw590
|
||||||
|
} > /tmp/ssw590/install.txt 2>&1
|
||||||
|
echo startup > /tmp/ssw590/phase
|
||||||
|
# Replace the preparer with the normal official Jenkins launcher, as non-root.
|
||||||
|
exec runuser -u jenkins -- /usr/bin/tini -- /usr/local/bin/jenkins.sh
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// Disposable, locally supplied fixture; no SCM credentials or production checkout.
|
||||||
|
node {
|
||||||
|
stage('Dependencies') {
|
||||||
|
sh 'python3 --version && git --version'
|
||||||
|
}
|
||||||
|
stage('Fresh fixture') {
|
||||||
|
// Delete only this disposable job workspace, inside the test container.
|
||||||
|
deleteDir()
|
||||||
|
sh 'cp -R /opt/ssw590-input/fixtures/. .'
|
||||||
|
if (params.BREAK_CALCULATION) {
|
||||||
|
sh '''python3 - <<'PY'
|
||||||
|
from pathlib import Path
|
||||||
|
p = Path('pricing.py')
|
||||||
|
s = p.read_text()
|
||||||
|
assert s.count('return unit_price * quantity') == 1
|
||||||
|
p.write_text(s.replace('return unit_price * quantity', 'return unit_price + quantity'))
|
||||||
|
PY'''
|
||||||
|
}
|
||||||
|
sh 'sha256sum pricing.py'
|
||||||
|
}
|
||||||
|
stage('Syntax') {
|
||||||
|
sh 'python3 -m py_compile pricing.py'
|
||||||
|
}
|
||||||
|
stage('Unit tests') {
|
||||||
|
sh 'python3 -m unittest discover -s tests -v'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
def total_price(unit_price, quantity):
|
||||||
|
if quantity < 1:
|
||||||
|
raise ValueError("Quantity must be positive")
|
||||||
|
return unit_price * quantity
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from pricing import total_price
|
||||||
|
|
||||||
|
|
||||||
|
class PricingTests(unittest.TestCase):
|
||||||
|
def test_total(self):
|
||||||
|
self.assertEqual(total_price(10, 3), 30)
|
||||||
|
|
||||||
|
def test_invalid_quantity(self):
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
total_price(10, 0)
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import groovy.json.JsonOutput
|
||||||
|
import hudson.init.InitMilestone
|
||||||
|
import hudson.model.BooleanParameterDefinition
|
||||||
|
import hudson.model.BooleanParameterValue
|
||||||
|
import hudson.model.ParametersAction
|
||||||
|
import hudson.model.ParametersDefinitionProperty
|
||||||
|
import hudson.security.FullControlOnceLoggedInAuthorizationStrategy
|
||||||
|
import hudson.security.HudsonPrivateSecurityRealm
|
||||||
|
import hudson.security.ACL
|
||||||
|
import jenkins.model.Jenkins
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
// Trusted administrator bootstrap, only in a new temporary home. Never log secrets.
|
||||||
|
def j = Jenkins.get()
|
||||||
|
def realm = new HudsonPrivateSecurityRealm(false)
|
||||||
|
realm.createAccount('capacity-test', UUID.randomUUID().toString() + UUID.randomUUID().toString())
|
||||||
|
j.setSecurityRealm(realm)
|
||||||
|
def authorization = new FullControlOnceLoggedInAuthorizationStrategy()
|
||||||
|
authorization.setAllowAnonymousRead(false)
|
||||||
|
j.setAuthorizationStrategy(authorization)
|
||||||
|
j.setNumExecutors(1)
|
||||||
|
j.setQuietPeriod(0)
|
||||||
|
j.save()
|
||||||
|
|
||||||
|
def root = new File('/tmp/ssw590')
|
||||||
|
def state = [phase: 'initializing', builds: []]
|
||||||
|
def writeState = {
|
||||||
|
def temporary = new File(root, 'status.next')
|
||||||
|
temporary.text = JsonOutput.toJson(state)
|
||||||
|
java.nio.file.Files.move(temporary.toPath(), new File(root, 'status.json').toPath(),
|
||||||
|
java.nio.file.StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
java.nio.file.StandardCopyOption.ATOMIC_MOVE)
|
||||||
|
}
|
||||||
|
writeState()
|
||||||
|
|
||||||
|
Thread.startDaemon('ssw590-disposable-test') {
|
||||||
|
// The trusted bootstrap worker needs the same system identity as the init hook.
|
||||||
|
def securityContext = ACL.as2(ACL.SYSTEM2)
|
||||||
|
try {
|
||||||
|
while (j.getInitLevel() != InitMilestone.COMPLETED) { Thread.sleep(1000) }
|
||||||
|
state.plugins = j.pluginManager.plugins.collect {
|
||||||
|
[id: it.shortName, version: it.version, active: it.isActive()]
|
||||||
|
}
|
||||||
|
state.failedPlugins = j.pluginManager.failedPlugins.collect { it.name }
|
||||||
|
def requested = new File('/opt/ssw590-input/plugins.txt').readLines().findAll { it.trim() }
|
||||||
|
requested.each { entry ->
|
||||||
|
def (id, version) = entry.trim().split(':', 2)
|
||||||
|
def p = j.pluginManager.getPlugin(id)
|
||||||
|
if (p == null || !p.isActive() || p.version != version) {
|
||||||
|
throw new IllegalStateException('Requested plugin not active at expected version: ' + id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state.failedPlugins || state.plugins.any { !it.active }) {
|
||||||
|
throw new IllegalStateException('Plugin load failure; inspect recorded inventory')
|
||||||
|
}
|
||||||
|
// Access plugin classes only after checking that they loaded.
|
||||||
|
def jobClass = j.pluginManager.uberClassLoader.loadClass('org.jenkinsci.plugins.workflow.job.WorkflowJob')
|
||||||
|
def definitionClass = j.pluginManager.uberClassLoader.loadClass('org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition')
|
||||||
|
def job = j.createProject(jobClass, 'capacity-pricing')
|
||||||
|
job.addProperty(new ParametersDefinitionProperty(
|
||||||
|
new BooleanParameterDefinition('BREAK_CALCULATION', false, 'Disposable failure exercise')))
|
||||||
|
job.setDefinition(definitionClass.getConstructor(String.class, Boolean.TYPE).newInstance(
|
||||||
|
new File('/opt/ssw590-input/fixtures/Jenkinsfile').text, true))
|
||||||
|
job.save()
|
||||||
|
state.phase = 'ready'
|
||||||
|
writeState()
|
||||||
|
// Host must observe >=60 seconds of healthy HTTP AFTER plugin checks first.
|
||||||
|
while (!new File(root, 'start-jobs').exists()) { Thread.sleep(1000) }
|
||||||
|
state.phase = 'pipelines'
|
||||||
|
writeState()
|
||||||
|
def cases = [[name: 'pass', broken: false, expected: 'SUCCESS'],
|
||||||
|
[name: 'intentional-failure', broken: true, expected: 'FAILURE'],
|
||||||
|
[name: 'repair', broken: false, expected: 'SUCCESS']]
|
||||||
|
for (testCase in cases) {
|
||||||
|
def future = job.scheduleBuild2(0, new ParametersAction(
|
||||||
|
new BooleanParameterValue('BREAK_CALCULATION', testCase.broken)))
|
||||||
|
if (future == null) { throw new IllegalStateException('Build could not be scheduled') }
|
||||||
|
def build = future.get(180, TimeUnit.SECONDS)
|
||||||
|
// Only these known fixture-job logs are copied, never controller logs.
|
||||||
|
def console = build.getLog(500).join('\n') + '\n'
|
||||||
|
new File(root, testCase.name + '-console.txt').text = console
|
||||||
|
def observed = build.result.toString()
|
||||||
|
state.builds << [name: testCase.name, number: build.number,
|
||||||
|
expected: testCase.expected, actual: observed]
|
||||||
|
writeState()
|
||||||
|
if (observed != testCase.expected) {
|
||||||
|
throw new IllegalStateException('Unexpected fixture build result: ' + testCase.name)
|
||||||
|
}
|
||||||
|
if (!console.contains('Ran 2 tests')) {
|
||||||
|
throw new IllegalStateException('Unit tests did not actually execute')
|
||||||
|
}
|
||||||
|
if (testCase.broken && (!console.contains('13 != 30') || !console.contains('FAILED (failures=1)'))) {
|
||||||
|
throw new IllegalStateException('Failure was not the intended calculation assertion')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.phase = 'complete'
|
||||||
|
writeState()
|
||||||
|
} catch (Throwable failure) {
|
||||||
|
state.phase = 'failed'
|
||||||
|
// Fixed harness error text/type; do not dump arbitrary stack traces or secrets.
|
||||||
|
state.errorType = failure.class.name
|
||||||
|
writeState()
|
||||||
|
} finally {
|
||||||
|
securityContext.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
"""Inspect downloaded plugin archives without loading Jenkins or reading secrets."""
|
||||||
|
import email.parser
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
|
||||||
|
def inventory(directory, requested):
|
||||||
|
entries = []
|
||||||
|
for path in sorted(Path(directory).glob("*.jpi")):
|
||||||
|
with zipfile.ZipFile(path) as archive:
|
||||||
|
raw = archive.read("META-INF/MANIFEST.MF").decode("utf-8")
|
||||||
|
# JAR manifests fold lines by prefixing continuation lines with one space.
|
||||||
|
unfolded = raw.replace("\r\n ", "").replace("\n ", "")
|
||||||
|
manifest = email.parser.Parser().parsestr(unfolded)
|
||||||
|
with path.open("rb") as stream:
|
||||||
|
digest = hashlib.file_digest(stream, "sha256").hexdigest() if hasattr(hashlib, "file_digest") else None
|
||||||
|
if digest is None:
|
||||||
|
h = hashlib.sha256()
|
||||||
|
with path.open("rb") as stream:
|
||||||
|
for block in iter(lambda: stream.read(1024 * 1024), b""):
|
||||||
|
h.update(block)
|
||||||
|
digest = h.hexdigest()
|
||||||
|
entries.append({"id": manifest["Short-Name"], "version": manifest["Plugin-Version"],
|
||||||
|
"requires_jenkins": manifest["Jenkins-Version"], "sha256": digest})
|
||||||
|
versions = {p["id"]: p["version"] for p in entries}
|
||||||
|
roots = [line.strip().split(":") for line in Path(requested).read_text().splitlines() if line.strip()]
|
||||||
|
for name, version in roots:
|
||||||
|
if versions.get(name) != version:
|
||||||
|
raise ValueError(f"Requested root version was not installed exactly: {name}:{version}")
|
||||||
|
if not entries:
|
||||||
|
raise ValueError("No plugin archives found")
|
||||||
|
return entries
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(json.dumps(inventory(sys.argv[1], sys.argv[2]), indent=2))
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
workflow-aggregator:608.v67378e9d3db_1
|
||||||
|
gitea:286.v0740a_413c1eb_
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
"""Resolve plugins on Windows Docker Desktop, never on the small droplet.
|
||||||
|
|
||||||
|
This launches only the official plugin installer, not Jenkins. The output is
|
||||||
|
non-secret plugin archives plus a hash/version manifest for the runtime test.
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import inventory
|
||||||
|
from run_test import IMAGE, LABEL, command, remove_owned
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--output", type=Path, required=True, help="NEW local plugin-bundle directory")
|
||||||
|
args = parser.parse_args()
|
||||||
|
if sys.platform != "win32":
|
||||||
|
parser.error("Prepare on Windows Docker Desktop; do not run this on the 512 MB droplet")
|
||||||
|
output = args.output.resolve()
|
||||||
|
if output.exists():
|
||||||
|
parser.error("Output already exists; preserve or review it before preparing another bundle")
|
||||||
|
bundle = Path(__file__).resolve().parent
|
||||||
|
owner = "prepare-" + datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ").lower()
|
||||||
|
container = None
|
||||||
|
output.mkdir(parents=True)
|
||||||
|
metadata = {"status": "INCOMPLETE", "environment": "Windows Docker Desktop plugin preparation only",
|
||||||
|
"base_image": IMAGE, "ram_mib": 768, "ram_plus_swap_mib": 1024,
|
||||||
|
"heap_max_mib": 512, "cpu": 1, "jenkins_started": False}
|
||||||
|
try:
|
||||||
|
if command("docker", "info", "--format", "{{.OSType}}").stdout.strip() != "linux":
|
||||||
|
raise RuntimeError("Use Docker Desktop's Linux engine")
|
||||||
|
if command("docker", "image", "inspect", IMAGE, check=False).returncode:
|
||||||
|
command("docker", "pull", IMAGE, timeout=300)
|
||||||
|
container = "ssw590-jenkins-" + owner
|
||||||
|
container = command("docker", "create", "--name", container,
|
||||||
|
"--label", f"{LABEL}={owner}", "--restart", "no",
|
||||||
|
"--memory", "768m", "--memory-swap", "1024m", "--cpus", "1", "--pids-limit", "256",
|
||||||
|
"--mount", f"type=bind,src={bundle},dst=/opt/ssw590-input,readonly",
|
||||||
|
"--env", "JAVA_OPTS=-Xms32m -Xmx512m -XX:+UseSerialGC",
|
||||||
|
"--entrypoint", "/bin/bash", IMAGE, "-c",
|
||||||
|
"mkdir -p /tmp/ssw590-prepared/plugins; "
|
||||||
|
"jenkins-plugin-cli --war /usr/share/jenkins/jenkins.war "
|
||||||
|
"--plugin-file /opt/ssw590-input/plugins.txt "
|
||||||
|
"--plugin-download-directory /tmp/ssw590-prepared/plugins --latest true --list "
|
||||||
|
"> /tmp/ssw590-prepared/installer.txt 2>&1").stdout.strip()
|
||||||
|
with (output / "preparer-process.txt").open("w") as log:
|
||||||
|
subprocess.run(["docker", "start", "--attach", container], stdout=log,
|
||||||
|
stderr=subprocess.STDOUT, timeout=900, check=True)
|
||||||
|
command("docker", "cp", container + ":/tmp/ssw590-prepared/plugins/.", str(output), timeout=60)
|
||||||
|
command("docker", "cp", container + ":/tmp/ssw590-prepared/installer.txt", str(output / "installer.txt"))
|
||||||
|
plugins = inventory.inventory(output, bundle / "plugins.txt")
|
||||||
|
(output / "manifest.json").write_text(json.dumps({"base_image": IMAGE, "plugins": plugins}, indent=2) + "\n")
|
||||||
|
(output / "plugins.lock").write_text("".join(p["id"] + ":" + p["version"] + "\n" for p in plugins))
|
||||||
|
metadata.update(status="PASS", plugin_count=len(plugins))
|
||||||
|
except Exception as error:
|
||||||
|
metadata.update(status="FAILED", reason=str(error))
|
||||||
|
if container:
|
||||||
|
command("docker", "cp", container + ":/tmp/ssw590-prepared/installer.txt",
|
||||||
|
str(output / "installer.txt"), check=False)
|
||||||
|
finally:
|
||||||
|
metadata["cleanup_ok"] = remove_owned(container, owner) if container else True
|
||||||
|
if not metadata["cleanup_ok"]:
|
||||||
|
metadata["status"] = "NEEDS_ATTENTION"
|
||||||
|
(output / "preparation.json").write_text(json.dumps(metadata, indent=2) + "\n")
|
||||||
|
print(json.dumps(metadata, indent=2))
|
||||||
|
return 0 if metadata["status"] == "PASS" else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,402 @@
|
|||||||
|
"""Bounded, disposable Jenkins plugin/pipeline experiment for The-Ocean.
|
||||||
|
|
||||||
|
No SSH, real account credentials, production mounts or host package changes are used.
|
||||||
|
Run --help for opt-in The-Ocean execution or Windows Docker Desktop validation.
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import signal
|
||||||
|
import socket
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import urllib.error
|
||||||
|
import urllib.request
|
||||||
|
import inventory
|
||||||
|
|
||||||
|
IMAGE = ("jenkins/jenkins:2.580.1-jdk21@sha256:"
|
||||||
|
"a660310e39ade10631f774bacd5219de767dfd08947ea5c32a739b5e5bb382c1")
|
||||||
|
LABEL = "ssw590.capacity-owner"
|
||||||
|
SITE = "https://git.yebilly.me"
|
||||||
|
PORT = 18080
|
||||||
|
BOUNDS = ["--memory", "256m", "--memory-swap", "512m", "--cpus", "0.5", "--pids-limit", "256"]
|
||||||
|
INSTALL_SECONDS = 1200
|
||||||
|
STARTUP_SECONDS = 900
|
||||||
|
PIPELINE_SECONDS = 600
|
||||||
|
TOTAL_SECONDS = 2700
|
||||||
|
IDLE_SECONDS = 60
|
||||||
|
OPENER = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||||
|
|
||||||
|
|
||||||
|
class Abort(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def utc():
|
||||||
|
return datetime.now(timezone.utc).isoformat(timespec="seconds")
|
||||||
|
|
||||||
|
|
||||||
|
def command(*args, timeout=15, check=True):
|
||||||
|
result = subprocess.run(args, capture_output=True, text=True, timeout=timeout)
|
||||||
|
if check and result.returncode:
|
||||||
|
# All invoked commands have non-secret arguments and output by construction.
|
||||||
|
raise Abort(f"Command failed: {args[0]} {args[1:3]}: {result.stderr.strip()[:500]}")
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def http_code(url):
|
||||||
|
try:
|
||||||
|
with OPENER.open(url, timeout=6) as response:
|
||||||
|
return response.status
|
||||||
|
except urllib.error.HTTPError as error:
|
||||||
|
return error.code
|
||||||
|
except (urllib.error.URLError, TimeoutError, OSError):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def host_memory():
|
||||||
|
fields = {}
|
||||||
|
for line in Path("/proc/meminfo").read_text().splitlines():
|
||||||
|
key, value = line.split(":", 1)
|
||||||
|
fields[key] = int(value.strip().split()[0])
|
||||||
|
return fields["MemAvailable"], fields["SwapFree"]
|
||||||
|
|
||||||
|
|
||||||
|
def resource_guard(available, swap_free, initial=False):
|
||||||
|
memory_floor, swap_floor = (131072, 524288) if initial else (49152, 131072)
|
||||||
|
if available < memory_floor:
|
||||||
|
raise Abort(f"Host available RAM below {memory_floor // 1024} MiB")
|
||||||
|
if swap_free < swap_floor:
|
||||||
|
raise Abort(f"Host free swap below {swap_floor // 1024} MiB")
|
||||||
|
|
||||||
|
|
||||||
|
def advance_idle(previous, completed_at, healthy):
|
||||||
|
"""The clock starts AFTER a successful HTTP probe, and resets on failure."""
|
||||||
|
if not healthy:
|
||||||
|
return None, False
|
||||||
|
started = completed_at if previous is None else previous
|
||||||
|
return started, completed_at - started >= IDLE_SECONDS
|
||||||
|
|
||||||
|
|
||||||
|
def parse_cgroup(raw):
|
||||||
|
result = {}
|
||||||
|
section = None
|
||||||
|
for line in raw.splitlines():
|
||||||
|
if line in ("memory.current", "memory.swap.current", "memory.events", "cpu.stat"):
|
||||||
|
section = line
|
||||||
|
result[section] = {} if section in ("memory.events", "cpu.stat") else None
|
||||||
|
elif section in ("memory.events", "cpu.stat"):
|
||||||
|
key, value = line.split()
|
||||||
|
result[section][key] = int(value)
|
||||||
|
elif section:
|
||||||
|
result[section] = int(line)
|
||||||
|
if any(result.get(key) is None for key in ("memory.current", "memory.swap.current", "memory.events", "cpu.stat")):
|
||||||
|
raise Abort("Incomplete cgroup accounting")
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def owned_container(container, owner):
|
||||||
|
result = command("docker", "inspect", "--format", '{{index .Config.Labels "' + LABEL + '"}}',
|
||||||
|
container, check=False)
|
||||||
|
return result.returncode == 0 and result.stdout.strip() == owner
|
||||||
|
|
||||||
|
|
||||||
|
def remove_owned(container, owner):
|
||||||
|
if not owned_container(container, owner):
|
||||||
|
return False
|
||||||
|
command("docker", "stop", "--time", "10", container, timeout=20, check=False)
|
||||||
|
result = command("docker", "rm", "--force", "--volumes", container, timeout=20, check=False)
|
||||||
|
return result.returncode == 0
|
||||||
|
|
||||||
|
|
||||||
|
def watchdog(container, owner, evidence):
|
||||||
|
# Detached from SSH. This child can delete ONLY this exact, owner-labelled test.
|
||||||
|
time.sleep(TOTAL_SECONDS + 60)
|
||||||
|
if owned_container(container, owner):
|
||||||
|
removed = remove_owned(container, owner)
|
||||||
|
(evidence / "watchdog.txt").write_text(f"{utc()} deadline expired; removed={removed}\n")
|
||||||
|
|
||||||
|
|
||||||
|
class Experiment:
|
||||||
|
def __init__(self, bundle, evidence, local=False, plugin_bundle=None):
|
||||||
|
self.bundle = bundle.resolve()
|
||||||
|
self.evidence = evidence
|
||||||
|
self.local = local
|
||||||
|
self.plugin_bundle = (plugin_bundle or self.bundle / "prepared-plugins").resolve()
|
||||||
|
self.owner = evidence.name
|
||||||
|
self.name = "ssw590-jenkins-plugins-" + self.owner.lower()
|
||||||
|
self.container = None
|
||||||
|
self.guard = None
|
||||||
|
self.result = {"status": "INCOMPLETE", "started": utc(), "scope": "disposable plugin/pipeline capacity",
|
||||||
|
"environment": "local Docker Desktop; NOT droplet capacity" if local else "The-Ocean"}
|
||||||
|
|
||||||
|
def save(self, filename, value):
|
||||||
|
(self.evidence / filename).write_text(json.dumps(value, indent=2) + "\n")
|
||||||
|
|
||||||
|
def preflight(self):
|
||||||
|
manifest = json.loads((self.plugin_bundle / "manifest.json").read_text())
|
||||||
|
if manifest.get("base_image") != IMAGE:
|
||||||
|
raise Abort("Plugin bundle was prepared for a different base image")
|
||||||
|
if manifest.get("plugins") != inventory.inventory(self.plugin_bundle, self.bundle / "plugins.txt"):
|
||||||
|
raise Abort("Plugin bundle version/hash verification failed")
|
||||||
|
self.save("prepared-plugin-manifest.json", manifest)
|
||||||
|
if self.local:
|
||||||
|
if sys.platform != "win32":
|
||||||
|
raise Abort("The local smoke-test option is for Windows Docker Desktop only")
|
||||||
|
else:
|
||||||
|
if sys.platform != "linux" or os.geteuid() != 0:
|
||||||
|
raise Abort("Run as root inside the authorized The-Ocean Linux SSH session")
|
||||||
|
if socket.gethostname().lower() != "the-ocean":
|
||||||
|
raise Abort("Unexpected host; this experiment is restricted to The-Ocean")
|
||||||
|
for tool in (("docker",) if self.local else ("docker", "free", "df", "swapon")):
|
||||||
|
if not shutil.which(tool):
|
||||||
|
raise Abort("Missing host command: " + tool)
|
||||||
|
if command("docker", "info", "--format", "{{.CgroupVersion}}").stdout.strip() != "2":
|
||||||
|
raise Abort("This recorder requires cgroup version 2")
|
||||||
|
if not self.local:
|
||||||
|
resource_guard(*host_memory(), initial=True)
|
||||||
|
if http_code(SITE) != 200:
|
||||||
|
raise Abort("Baseline Gitea HTTP check failed")
|
||||||
|
with socket.socket() as probe:
|
||||||
|
probe.bind(("127.0.0.1", PORT))
|
||||||
|
# One plugin experiment at a time, even before its HTTP port is published.
|
||||||
|
existing = command("docker", "ps", "-aq", "--filter", "label=ssw590.purpose=jenkins-plugin-capacity").stdout.strip()
|
||||||
|
if existing:
|
||||||
|
raise Abort("Another plugin-test container exists; inspect it before continuing")
|
||||||
|
if ":18080->" in command("docker", "ps", "--format", "{{.Ports}}").stdout:
|
||||||
|
raise Abort("A Docker container already publishes the test port")
|
||||||
|
present = command("docker", "image", "inspect", IMAGE, check=False).returncode == 0
|
||||||
|
docker_root = command("docker", "info", "--format", "{{.DockerRootDir}}").stdout.strip()
|
||||||
|
disk_floor = (2 if present else 3) * 1024 ** 3
|
||||||
|
if not self.local and shutil.disk_usage(docker_root).free < disk_floor:
|
||||||
|
raise Abort(f"Less than {disk_floor // 1024 ** 3} GiB free in Docker storage")
|
||||||
|
self.save("baseline.json", {"utc": utc(), "hostname": socket.gethostname(),
|
||||||
|
"environment": self.result["environment"],
|
||||||
|
"memory_available_kib": None if self.local else host_memory()[0],
|
||||||
|
"swap_free_kib": None if self.local else host_memory()[1],
|
||||||
|
"docker_free_bytes": None if self.local else shutil.disk_usage(docker_root).free,
|
||||||
|
"docker_engine": command("docker", "info", "--format", "OS={{.OSType}} CPUs={{.NCPU}} MemoryBytes={{.MemTotal}}").stdout,
|
||||||
|
"containers": command("docker", "ps", "--format", "{{.Names}} {{.Image}} {{.Status}} {{.Ports}}").stdout,
|
||||||
|
"memory": None if self.local else command("free", "-m").stdout,
|
||||||
|
"swap": None if self.local else command("swapon", "--show").stdout,
|
||||||
|
"disk": None if self.local else command("df", "-h", docker_root).stdout,
|
||||||
|
"reboot_required": None if self.local else Path("/var/run/reboot-required").exists()})
|
||||||
|
if not present:
|
||||||
|
# Explicitly separate the pull from constrained plugin/runtime measurements.
|
||||||
|
with (self.evidence / "image-pull.txt").open("w") as output:
|
||||||
|
subprocess.run(["docker", "pull", IMAGE], stdout=output, stderr=subprocess.STDOUT,
|
||||||
|
timeout=300, check=True)
|
||||||
|
if not self.local:
|
||||||
|
resource_guard(*host_memory(), initial=True)
|
||||||
|
self.save("image.json", json.loads(command("docker", "image", "inspect", "--format",
|
||||||
|
'{"id":{{json .Id}},"digests":{{json .RepoDigests}},"bytes":{{.Size}}}', IMAGE).stdout))
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
# Nothing under ~/gitea, no real Jenkins home, socket, tokens or runner state.
|
||||||
|
# Preserve a cleanup handle even if Docker creates it but the CLI times out.
|
||||||
|
self.container = self.name
|
||||||
|
self.container = command("docker", "create", "--name", self.name,
|
||||||
|
"--label", "ssw590.purpose=jenkins-plugin-capacity", "--label", f"{LABEL}={self.owner}",
|
||||||
|
"--restart", "no", *BOUNDS, "--publish", f"127.0.0.1:{PORT}:8080",
|
||||||
|
"--log-driver", "json-file", "--log-opt", "max-size=1m", "--log-opt", "max-file=1",
|
||||||
|
"--mount", f"type=bind,src={self.bundle},dst=/opt/ssw590-input,readonly",
|
||||||
|
"--mount", f"type=bind,src={self.plugin_bundle},dst=/opt/ssw590-plugins,readonly",
|
||||||
|
"--env", "SSW590_DISPOSABLE_TEST=1",
|
||||||
|
"--env", "JAVA_OPTS=-Xms32m -Xmx128m -XX:+UseSerialGC -Djenkins.install.runSetupWizard=false",
|
||||||
|
"--user", "root", "--entrypoint", "/bin/bash", IMAGE,
|
||||||
|
"/opt/ssw590-input/container.sh").stdout.strip()
|
||||||
|
if not self.container:
|
||||||
|
raise Abort("Docker did not return a container ID")
|
||||||
|
self.save("test-config.json", {"base_image": IMAGE, "container_id": self.container,
|
||||||
|
"container_name": self.name, "owner": self.owner,
|
||||||
|
"ram_mib": 256, "ram_plus_swap_mib": 512, "cpu": 0.5, "pids": 256,
|
||||||
|
"heap_max_mib": 128, "idle_seconds": IDLE_SECONDS, "total_timeout_seconds": TOTAL_SECONDS,
|
||||||
|
"requested_plugins": (self.bundle / "plugins.txt").read_text().splitlines(),
|
||||||
|
"scope_excludes": ["SCM checkout", "webhook", "status reporting", "merge gate", "production deployment"]})
|
||||||
|
# Start the independent cleanup deadline before launching the container.
|
||||||
|
self.guard = subprocess.Popen([sys.executable, str(Path(__file__).resolve()), "--watchdog",
|
||||||
|
self.container, self.owner, str(self.evidence)], stdin=subprocess.DEVNULL,
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=os.name != "nt",
|
||||||
|
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||||
|
command("docker", "start", self.container)
|
||||||
|
|
||||||
|
def read_file(self, name):
|
||||||
|
result = command("docker", "exec", self.container, "cat", "/tmp/ssw590/" + name,
|
||||||
|
timeout=8, check=False)
|
||||||
|
return result.stdout.strip() if result.returncode == 0 else ""
|
||||||
|
|
||||||
|
def sample(self):
|
||||||
|
available, swap_free = (None, None) if self.local else host_memory()
|
||||||
|
if not self.local:
|
||||||
|
resource_guard(available, swap_free)
|
||||||
|
if http_code(SITE) != 200:
|
||||||
|
raise Abort("Gitea sampled HTTP check failed; cause not established")
|
||||||
|
running = command("docker", "inspect", "--format", "{{.State.Running}}", self.container).stdout.strip()
|
||||||
|
if running != "true":
|
||||||
|
raise Abort("Test container exited; inspect final state/install diagnostics")
|
||||||
|
phase = self.read_file("phase") or "initializing"
|
||||||
|
raw_status = self.read_file("status.json")
|
||||||
|
status = json.loads(raw_status) if raw_status else {}
|
||||||
|
code = http_code(f"http://127.0.0.1:{PORT}/login") if phase == "startup" else 0
|
||||||
|
# Timestamp AFTER the HTTP response, avoiding the prior 54-second false pass.
|
||||||
|
completed_at = time.monotonic()
|
||||||
|
http_utc = utc()
|
||||||
|
stats = command("docker", "stats", "--no-stream", "--format", "{{json .}}", self.container,
|
||||||
|
timeout=10).stdout.strip()
|
||||||
|
counters = command("docker", "exec", self.container, "sh", "-c",
|
||||||
|
'for f in memory.current memory.swap.current memory.events cpu.stat; do '
|
||||||
|
'echo "$f"; cat "/sys/fs/cgroup/$f"; done', timeout=8, check=False)
|
||||||
|
if counters.returncode:
|
||||||
|
raise Abort("Cannot read cgroup v2 memory/swap/CPU counters")
|
||||||
|
accounting = parse_cgroup(counters.stdout)
|
||||||
|
record = {"utc": http_utc, "http_completed_monotonic_seconds": completed_at,
|
||||||
|
"phase": phase, "jenkins_phase": status.get("phase"),
|
||||||
|
"host_available_kib": available, "host_swap_free_kib": swap_free,
|
||||||
|
"gitea_http": None if self.local else 200, "jenkins_login_http": code,
|
||||||
|
"docker_stats": json.loads(stats), "cgroup": accounting}
|
||||||
|
with (self.evidence / "samples.jsonl").open("a") as output:
|
||||||
|
output.write(json.dumps(record) + "\n")
|
||||||
|
if accounting["memory.events"].get("oom", 0) or accounting["memory.events"].get("oom_kill", 0):
|
||||||
|
raise Abort("Container recorded an out-of-memory event")
|
||||||
|
host_summary = "host guards/Gitea check: droplet-only" if self.local else f"available={available // 1024}MiB swap-free={swap_free // 1024}MiB GiteaHTTP=200"
|
||||||
|
print(f"{record['utc']} {phase}/{status.get('phase', '-')} JenkinsHTTP={code} {host_summary}", flush=True)
|
||||||
|
return phase, status, code, completed_at
|
||||||
|
|
||||||
|
def monitor(self):
|
||||||
|
begin = time.monotonic()
|
||||||
|
startup = pipelines = idle = None
|
||||||
|
with (self.evidence / "checkpoints.jsonl").open("a") as checkpoints:
|
||||||
|
while True:
|
||||||
|
phase, status, code, now = self.sample()
|
||||||
|
if now - begin > TOTAL_SECONDS:
|
||||||
|
raise Abort("Overall experiment deadline exceeded")
|
||||||
|
if status.get("phase") == "failed":
|
||||||
|
self.save("jenkins-status.json", status)
|
||||||
|
raise Abort("Jenkins harness failed: " + status.get("errorType", "unknown"))
|
||||||
|
if phase != "startup":
|
||||||
|
if now - begin > INSTALL_SECONDS:
|
||||||
|
raise Abort("Tool/plugin installation deadline exceeded")
|
||||||
|
else:
|
||||||
|
if startup is None:
|
||||||
|
startup = now
|
||||||
|
if pipelines is None:
|
||||||
|
healthy = status.get("phase") == "ready" and code == 200
|
||||||
|
idle, passed = advance_idle(idle, now, healthy)
|
||||||
|
if passed:
|
||||||
|
checkpoints.write(json.dumps({"checkpoint": "plugins-and-idle", "utc": utc(),
|
||||||
|
"observed_seconds": now - idle}) + "\n")
|
||||||
|
checkpoints.flush()
|
||||||
|
self.save("jenkins-status-at-idle.json", status)
|
||||||
|
command("docker", "exec", self.container, "touch", "/tmp/ssw590/start-jobs")
|
||||||
|
pipelines = now
|
||||||
|
elif now - startup > STARTUP_SECONDS:
|
||||||
|
raise Abort("Plugin startup/healthy-idle deadline exceeded")
|
||||||
|
else:
|
||||||
|
if code != 200:
|
||||||
|
raise Abort("Jenkins HTTP check failed during pipeline exercise")
|
||||||
|
if now - pipelines > PIPELINE_SECONDS:
|
||||||
|
raise Abort("Pipeline exercise deadline exceeded")
|
||||||
|
if status.get("phase") == "complete":
|
||||||
|
builds = status.get("builds", [])
|
||||||
|
if [b.get("actual") for b in builds] != ["SUCCESS", "FAILURE", "SUCCESS"]:
|
||||||
|
raise Abort("Missing expected pass/fail/repair results")
|
||||||
|
self.save("jenkins-status.json", status)
|
||||||
|
self.result.update(status="PASS", details="Plugins active; >=60-second observed healthy idle; pass/fail/repair fixture pipeline")
|
||||||
|
return
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
cleanup_ok = True
|
||||||
|
if self.container:
|
||||||
|
try:
|
||||||
|
if not owned_container(self.container, self.owner):
|
||||||
|
raise Abort("Cleanup ownership check failed; refusing container deletion")
|
||||||
|
final = command("docker", "inspect", "--format", "{{json .State}}", self.container, check=False)
|
||||||
|
if final.returncode == 0:
|
||||||
|
self.save("final-container-state.json", json.loads(final.stdout))
|
||||||
|
# Explicit allowlist; no raw controller logs or Jenkins home/credentials.
|
||||||
|
for name in ("install.txt", "plugins-resolved.json", "plugins-resolved.lock", "status.json",
|
||||||
|
"pass-console.txt", "intentional-failure-console.txt", "repair-console.txt"):
|
||||||
|
command("docker", "cp", self.container + ":/tmp/ssw590/" + name,
|
||||||
|
str(self.evidence / name), timeout=15, check=False)
|
||||||
|
# Even if a diagnostic copy failed, finally below removes owned resources.
|
||||||
|
except Exception as error:
|
||||||
|
self.result["capture_error"] = str(error)
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
cleanup_ok = remove_owned(self.container, self.owner)
|
||||||
|
except Exception as error:
|
||||||
|
cleanup_ok = False
|
||||||
|
self.result["cleanup_error"] = str(error)
|
||||||
|
if self.guard and cleanup_ok:
|
||||||
|
self.guard.terminate()
|
||||||
|
try:
|
||||||
|
self.guard.wait(timeout=3)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
self.guard.kill()
|
||||||
|
self.guard.wait()
|
||||||
|
self.result.update(finished=utc(), cleanup_ok=cleanup_ok, gitea_http_after=None if self.local else http_code(SITE))
|
||||||
|
if self.result["status"] == "PASS":
|
||||||
|
required = ("install.txt", "plugins-resolved.json", "plugins-resolved.lock", "status.json",
|
||||||
|
"pass-console.txt", "intentional-failure-console.txt", "repair-console.txt")
|
||||||
|
missing = [name for name in required if not (self.evidence / name).is_file()]
|
||||||
|
if missing or self.result.get("capture_error"):
|
||||||
|
self.result.update(status="NEEDS_ATTENTION", missing_evidence=missing)
|
||||||
|
if not cleanup_ok or (not self.local and self.result["gitea_http_after"] != 200):
|
||||||
|
self.result["status"] = "NEEDS_ATTENTION"
|
||||||
|
self.save("result.json", self.result)
|
||||||
|
print(json.dumps(self.result, indent=2), flush=True)
|
||||||
|
print("Evidence: " + str(self.evidence), flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# This internal branch is intentionally unavailable from the public parser.
|
||||||
|
if len(sys.argv) == 5 and sys.argv[1] == "--watchdog":
|
||||||
|
watchdog(sys.argv[2], sys.argv[3], Path(sys.argv[4]))
|
||||||
|
return 0
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
modes = parser.add_mutually_exclusive_group()
|
||||||
|
modes.add_argument("--run-on-the-ocean", action="store_true", help="Execute the bounded experiment on the authorized droplet")
|
||||||
|
modes.add_argument("--local-smoke-test", action="store_true", help="Windows Docker Desktop runtime check; NOT droplet capacity")
|
||||||
|
parser.add_argument("--plugin-bundle", type=Path, help="Prepared archives directory; default: prepared-plugins beside this script")
|
||||||
|
args = parser.parse_args()
|
||||||
|
if not (args.run_on_the_ocean or args.local_smoke_test):
|
||||||
|
parser.print_help()
|
||||||
|
return 0
|
||||||
|
if args.run_on_the_ocean and (sys.platform != "linux" or os.geteuid() != 0 or socket.gethostname().lower() != "the-ocean"):
|
||||||
|
parser.error("Execution requires the root session on The-Ocean")
|
||||||
|
os.umask(0o077)
|
||||||
|
bundle = Path(__file__).resolve().parent
|
||||||
|
evidence_root = bundle.parents[1] / "build/evidence/jenkins-plugin-local" if args.local_smoke_test else Path("/root/ssw590-capacity-evidence")
|
||||||
|
evidence = evidence_root / ("plugins-" + datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ") + "-" + str(os.getpid()))
|
||||||
|
evidence.mkdir(parents=True, exist_ok=False)
|
||||||
|
experiment = Experiment(bundle, evidence, local=args.local_smoke_test, plugin_bundle=args.plugin_bundle)
|
||||||
|
# Keep source versions with measurements, but never copy unrelated repository data.
|
||||||
|
experiment.save("input-hashes.json", {str(p.relative_to(bundle)): hashlib.sha256(p.read_bytes()).hexdigest()
|
||||||
|
for p in bundle.rglob("*") if p.is_file() and "__pycache__" not in p.parts})
|
||||||
|
def interrupted(signum, frame):
|
||||||
|
raise Abort("Interrupted by signal " + str(signum))
|
||||||
|
watched_signals = [signal.SIGINT, signal.SIGTERM] + ([signal.SIGHUP] if hasattr(signal, "SIGHUP") else [])
|
||||||
|
for sig in watched_signals:
|
||||||
|
signal.signal(sig, interrupted)
|
||||||
|
try:
|
||||||
|
experiment.preflight()
|
||||||
|
experiment.create()
|
||||||
|
experiment.monitor()
|
||||||
|
except Exception as error:
|
||||||
|
experiment.result.update(status="FAILED_OR_ABORTED", reason=str(error))
|
||||||
|
finally:
|
||||||
|
# Prevent a second disconnect signal interrupting resource cleanup.
|
||||||
|
for sig in watched_signals:
|
||||||
|
signal.signal(sig, signal.SIG_IGN)
|
||||||
|
experiment.cleanup()
|
||||||
|
return 0 if experiment.result["status"] == "PASS" else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
"""Local fault/regression checks; these do not emulate a Jenkins runtime."""
|
||||||
|
import contextlib
|
||||||
|
import io
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parent
|
||||||
|
sys.path.insert(0, str(ROOT))
|
||||||
|
import run_test as harness
|
||||||
|
import inventory
|
||||||
|
|
||||||
|
|
||||||
|
class TimingAndProtectionTests(unittest.TestCase):
|
||||||
|
def test_previous_54_second_false_pass_is_rejected(self):
|
||||||
|
started, passed = harness.advance_idle(None, 100, True)
|
||||||
|
self.assertFalse(passed)
|
||||||
|
self.assertFalse(harness.advance_idle(started, 154, True)[1])
|
||||||
|
self.assertTrue(harness.advance_idle(started, 160, True)[1])
|
||||||
|
|
||||||
|
def test_failed_probe_restarts_the_idle_window(self):
|
||||||
|
started, _ = harness.advance_idle(None, 100, True)
|
||||||
|
started, passed = harness.advance_idle(started, 159, False)
|
||||||
|
self.assertIsNone(started)
|
||||||
|
started, passed = harness.advance_idle(started, 170, True)
|
||||||
|
self.assertFalse(passed)
|
||||||
|
self.assertFalse(harness.advance_idle(started, 229, True)[1])
|
||||||
|
self.assertTrue(harness.advance_idle(started, 230, True)[1])
|
||||||
|
|
||||||
|
def test_low_memory_or_swap_stops_the_experiment(self):
|
||||||
|
for available, swap in [(49151, 999999), (999999, 131071)]:
|
||||||
|
with self.assertRaises(harness.Abort):
|
||||||
|
harness.resource_guard(available, swap)
|
||||||
|
with self.assertRaises(harness.Abort):
|
||||||
|
harness.resource_guard(131071, 524288, initial=True)
|
||||||
|
harness.resource_guard(131072, 524288, initial=True)
|
||||||
|
|
||||||
|
def test_cleanup_refuses_other_owners(self):
|
||||||
|
wrong_owner = subprocess.CompletedProcess([], 0, stdout="someone-else\n", stderr="")
|
||||||
|
with patch.object(harness, "command", return_value=wrong_owner) as commands:
|
||||||
|
self.assertFalse(harness.remove_owned("unrelated-container", "our-run"))
|
||||||
|
self.assertEqual(commands.call_count, 1)
|
||||||
|
self.assertEqual(commands.call_args.args[:2], ("docker", "inspect"))
|
||||||
|
|
||||||
|
def test_cgroup_ram_swap_and_cpu_are_separate(self):
|
||||||
|
raw = "memory.current\n83513344\nmemory.swap.current\n221806592\nmemory.events\noom 0\noom_kill 0\ncpu.stat\nnr_periods 2090\nnr_throttled 1052\n"
|
||||||
|
result = harness.parse_cgroup(raw)
|
||||||
|
self.assertEqual(result["memory.current"] + result["memory.swap.current"], 305319936)
|
||||||
|
self.assertEqual(result["cpu.stat"]["nr_throttled"], 1052)
|
||||||
|
with self.assertRaises(harness.Abort):
|
||||||
|
harness.parse_cgroup("memory.current\n10\n")
|
||||||
|
|
||||||
|
|
||||||
|
class EvidenceAndFixtureTests(unittest.TestCase):
|
||||||
|
def test_monitor_waits_full_window_before_starting_jobs(self):
|
||||||
|
with tempfile.TemporaryDirectory() as temporary:
|
||||||
|
run = harness.Experiment(ROOT, Path(temporary))
|
||||||
|
run.container = 'our-test-id'
|
||||||
|
completed = {"phase": "complete", "builds": [{"actual": r} for r in ["SUCCESS", "FAILURE", "SUCCESS"]]}
|
||||||
|
samples = [("startup", {"phase": "ready"}, 200, t) for t in (100, 154, 160)]
|
||||||
|
samples.append(("startup", completed, 200, 170))
|
||||||
|
with patch.object(run, "sample", side_effect=samples), patch.object(harness.time, "monotonic", return_value=0), \
|
||||||
|
patch.object(harness.time, "sleep"), patch.object(harness, "command") as commands:
|
||||||
|
run.monitor()
|
||||||
|
commands.assert_called_once_with("docker", "exec", 'our-test-id', "touch", "/tmp/ssw590/start-jobs")
|
||||||
|
checkpoint = json.loads((Path(temporary) / "checkpoints.jsonl").read_text())
|
||||||
|
self.assertEqual(checkpoint["observed_seconds"], 60)
|
||||||
|
self.assertEqual(run.result["status"], "PASS")
|
||||||
|
|
||||||
|
def test_diagnostic_error_does_not_skip_targeted_cleanup(self):
|
||||||
|
with tempfile.TemporaryDirectory() as temporary:
|
||||||
|
run = harness.Experiment(ROOT, Path(temporary))
|
||||||
|
run.container = 'our-test-id'
|
||||||
|
with patch.object(harness, "owned_container", return_value=True), \
|
||||||
|
patch.object(harness, "command", side_effect=TimeoutError("diagnostic timed out")), \
|
||||||
|
patch.object(harness, "remove_owned", return_value=True) as remove, \
|
||||||
|
patch.object(harness, "http_code", return_value=200), contextlib.redirect_stdout(io.StringIO()):
|
||||||
|
run.cleanup()
|
||||||
|
remove.assert_called_once_with('our-test-id', run.owner)
|
||||||
|
self.assertTrue(run.result["cleanup_ok"])
|
||||||
|
|
||||||
|
def test_folded_plugin_manifest_and_root_mismatch(self):
|
||||||
|
with tempfile.TemporaryDirectory() as temporary:
|
||||||
|
root = Path(temporary)
|
||||||
|
requested = root / "plugins.txt"
|
||||||
|
requested.write_text("gitea:286.v0740a_413c1eb_\n")
|
||||||
|
with zipfile.ZipFile(root / "gitea.jpi", "w") as archive:
|
||||||
|
archive.writestr("META-INF/MANIFEST.MF", "Manifest-Version: 1.0\r\nShort-Name: gitea\r\nPlugin-Version: 286.v0740a_\r\n 413c1eb_\r\nJenkins-Version: 2.528.3\r\n\r\n")
|
||||||
|
result = inventory.inventory(root, requested)
|
||||||
|
self.assertEqual(result[0]["version"], "286.v0740a_413c1eb_")
|
||||||
|
self.assertEqual(len(result[0]["sha256"]), 64)
|
||||||
|
requested.write_text("gitea:wrong\n")
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
inventory.inventory(root, requested)
|
||||||
|
|
||||||
|
def test_real_python_fixture_pass_failure_and_repair(self):
|
||||||
|
with tempfile.TemporaryDirectory() as temporary:
|
||||||
|
working = Path(temporary)
|
||||||
|
shutil.copytree(ROOT / "fixtures", working, dirs_exist_ok=True)
|
||||||
|
pricing = working / "pricing.py"
|
||||||
|
original = pricing.read_text()
|
||||||
|
for broken, expected in ((False, 0), (True, 1), (False, 0)):
|
||||||
|
pricing.write_text(original.replace("return unit_price * quantity", "return unit_price + quantity") if broken else original)
|
||||||
|
# Fresh process and no stale bytecode even if file timestamps collide.
|
||||||
|
shutil.rmtree(working / "__pycache__", ignore_errors=True)
|
||||||
|
run = subprocess.run([sys.executable, "-B", "-m", "unittest", "discover", "-s", "tests", "-v"],
|
||||||
|
cwd=working, capture_output=True, text=True)
|
||||||
|
self.assertEqual(run.returncode, expected, run.stderr)
|
||||||
|
self.assertIn("Ran 2 tests", run.stderr)
|
||||||
|
if broken:
|
||||||
|
self.assertIn("13 != 30", run.stderr)
|
||||||
|
self.assertIn("FAILED (failures=1)", run.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main(verbosity=2)
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
# Regenerate the whole file from a new bundle manifest rather than hand-editing one line.
|
# Regenerate the whole file from a new bundle manifest rather than hand-editing one line.
|
||||||
# Added 2026-10-22: matrix-auth:3.3 for named Jenkins roles (its only dependency, ionicons-api,
|
# Added 2026-10-22: matrix-auth:3.3 for named Jenkins roles (its only dependency, ionicons-api,
|
||||||
# was already in the bundle at the required version).
|
# was already in the bundle at the required version).
|
||||||
|
# Added 2026-10-23: pipeline-graph-view (stage view of each run) with its new dependencies
|
||||||
|
# jackson3-api and snakeyaml-engine-api; other required versions were already satisfied.
|
||||||
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83:cea2f61cc72890b962fd4b767c31778c6cb30015b4a8758b4c26b62e51ca9533
|
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83:cea2f61cc72890b962fd4b767c31778c6cb30015b4a8758b4c26b62e51ca9533
|
||||||
asm-api:9.11.1-226.vff833a_e4c58e:ba315fe727be0311cd5115205a09a2abb550b73287cc4ee07af5f7ef6502f1f8
|
asm-api:9.11.1-226.vff833a_e4c58e:ba315fe727be0311cd5115205a09a2abb550b73287cc4ee07af5f7ef6502f1f8
|
||||||
authentication-tokens:1.144.v5ff4a_5ec5c33:8069074af688b102703410045a11394fb8d2f52c2cc2d7abd3067e3adff5fc24
|
authentication-tokens:1.144.v5ff4a_5ec5c33:8069074af688b102703410045a11394fb8d2f52c2cc2d7abd3067e3adff5fc24
|
||||||
@@ -26,6 +28,7 @@ instance-identity:203.v15e81a_1b_7a_38:df2b3205a6177248f12b294650a60405f65ba2cd5
|
|||||||
ionicons-api:94.vcc3065403257:95f3504375d628d887425ccdf32d5606a230261ee42dc683f13958d8e973ac3f
|
ionicons-api:94.vcc3065403257:95f3504375d628d887425ccdf32d5606a230261ee42dc683f13958d8e973ac3f
|
||||||
jackson-annotations2-api:2.22-19.v10a_a_582ea_26e:f13d0a17af6f8c8939a6edd30952006b77dca4760b1f40e0289c363918b7d17d
|
jackson-annotations2-api:2.22-19.v10a_a_582ea_26e:f13d0a17af6f8c8939a6edd30952006b77dca4760b1f40e0289c363918b7d17d
|
||||||
jackson2-api:2.22.3-447.v6a_93ce7d2c82:ce2cfb7a5ad6e66aea9a5b6c4a5ea0622bfc5c05db5db8918581ae7f1d10ff33
|
jackson2-api:2.22.3-447.v6a_93ce7d2c82:ce2cfb7a5ad6e66aea9a5b6c4a5ea0622bfc5c05db5db8918581ae7f1d10ff33
|
||||||
|
jackson3-api:3.2.4-103.vf5a_b_3f4ea_cec:4397f73c11ba5085a40280555b519c9427cf8d69d63d5d60f4f623f72f953fe2
|
||||||
jakarta-activation-api:2.1.4-1:e62298341742f14b374045387ba641ad8a19376793c76bdafebb4a05b5099712
|
jakarta-activation-api:2.1.4-1:e62298341742f14b374045387ba641ad8a19376793c76bdafebb4a05b5099712
|
||||||
jakarta-mail-api:2.1.5-1:244735ea85a51332c079d235a5713e70d3810bea62332894002acc39914ce11b
|
jakarta-mail-api:2.1.5-1:244735ea85a51332c079d235a5713e70d3810bea62332894002acc39914ce11b
|
||||||
jakarta-xml-bind-api:4.0.9-19.v2b_a_5b_44d9a_1c:2f59227936687ec00f7ea62b550e7a6e9c86cda3423f3567ffe66bbdf235ffb5
|
jakarta-xml-bind-api:4.0.9-19.v2b_a_5b_44d9a_1c:2f59227936687ec00f7ea62b550e7a6e9c86cda3423f3567ffe66bbdf235ffb5
|
||||||
@@ -38,6 +41,7 @@ matrix-auth:3.3:b8f7a916f1de0872d4c16264bcf9604fdb5b2da1827764745946c7ac5f613948
|
|||||||
mina-sshd-api-common:2.19.0-192.v2b_a_7b_2c1dc71:887ebd645e43919b6113201257821b990fc923f375382a5dada0c089e49b85bc
|
mina-sshd-api-common:2.19.0-192.v2b_a_7b_2c1dc71:887ebd645e43919b6113201257821b990fc923f375382a5dada0c089e49b85bc
|
||||||
mina-sshd-api-core:2.19.0-192.v2b_a_7b_2c1dc71:5039ea17ea1aa9e349712ccc1e036c38ea9f20f722affc220c2c751369f32495
|
mina-sshd-api-core:2.19.0-192.v2b_a_7b_2c1dc71:5039ea17ea1aa9e349712ccc1e036c38ea9f20f722affc220c2c751369f32495
|
||||||
pipeline-build-step:601.v6d4c6d1a_9dc7:1b61a1820844f3f72f9dfcd6d7eeab66fa0fbcee5e3923b912cd1ed10fbf63c5
|
pipeline-build-step:601.v6d4c6d1a_9dc7:1b61a1820844f3f72f9dfcd6d7eeab66fa0fbcee5e3923b912cd1ed10fbf63c5
|
||||||
|
pipeline-graph-view:1053.v9df19e6ceed2:4a92651101fb02e0db24170211ef1b4cc14b7d3c20df51a2fa61807f75bff8ff
|
||||||
pipeline-groovy-lib:822.vc95f70dea_db_7:a633824da17e95fe2a9f03e8d951a771c70a729e987fc51874146723f3b6343b
|
pipeline-groovy-lib:822.vc95f70dea_db_7:a633824da17e95fe2a9f03e8d951a771c70a729e987fc51874146723f3b6343b
|
||||||
pipeline-input-step:560.v56198a_642157:7c61bb745ecd1e4e5c7864dc7c8352148d9b2281bcca5a48fd3a7cca7290a135
|
pipeline-input-step:560.v56198a_642157:7c61bb745ecd1e4e5c7864dc7c8352148d9b2281bcca5a48fd3a7cca7290a135
|
||||||
pipeline-milestone-step:152.v6e22b_8cfc66c:cb3187809e219f01b42068f277058a818033f3cfd14da7ec59c86f028fc38386
|
pipeline-milestone-step:152.v6e22b_8cfc66c:cb3187809e219f01b42068f277058a818033f3cfd14da7ec59c86f028fc38386
|
||||||
@@ -50,6 +54,7 @@ plain-credentials:199.v9f8e1f741799:b5e5e35cf93ad3b818a983916cbcdf3f7866699410a4
|
|||||||
scm-api:728.vc30dcf7a_0df5:1336472987daa2fa912210aba00e1e37b739ce03f75c973a6794d1a0f55c0326
|
scm-api:728.vc30dcf7a_0df5:1336472987daa2fa912210aba00e1e37b739ce03f75c973a6794d1a0f55c0326
|
||||||
script-security:1436.v1082791135e4:c2292e200c5796675c16d19325469aac4a5460c7ad23974952b9823f62066f6a
|
script-security:1436.v1082791135e4:c2292e200c5796675c16d19325469aac4a5460c7ad23974952b9823f62066f6a
|
||||||
snakeyaml-api:2.7-152.vc672728cf536:bfa595a283634c8dd63aa8d1b039cf3d3f52e0952048058fc0b9a4826ca06508
|
snakeyaml-api:2.7-152.vc672728cf536:bfa595a283634c8dd63aa8d1b039cf3d3f52e0952048058fc0b9a4826ca06508
|
||||||
|
snakeyaml-engine-api:3.2-18.v885ed7ff698f:89c14c0ac2816c1efc192dd333b4b26d97ae58d2ab1d492e8b52feca406e220e
|
||||||
ssh-credentials:372.va_250881b_08cd:7b4d035b05b331038f3dfa99ddfef0cabbacede8f0ad2a6ca9611fb0844108a9
|
ssh-credentials:372.va_250881b_08cd:7b4d035b05b331038f3dfa99ddfef0cabbacede8f0ad2a6ca9611fb0844108a9
|
||||||
structs:362.va_b_695ef4fdf9:a0a5db44f2cb082a9ec6572c088340521f033fff8c351fc7eba9ef7f07dbbf8d
|
structs:362.va_b_695ef4fdf9:a0a5db44f2cb082a9ec6572c088340521f033fff8c351fc7eba9ef7f07dbbf8d
|
||||||
variant:70.va_d9f17f859e0:12e214ea694469a4461b55881ecb4074ae5dfb04797dbc0dad390f6f4bc75aaf
|
variant:70.va_d9f17f859e0:12e214ea694469a4461b55881ecb4074ae5dfb04797dbc0dad390f6f4bc75aaf
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
This group document records the SSW 590 coursework and its supporting
|
This group document records the SSW 590 coursework and its supporting
|
||||||
commands, designs, and evidence. Assignment 5 automates compilation of the
|
commands, designs, and evidence. Assignment 6 adds continuous integration:
|
||||||
LaTeX manual through Gitea Actions, using a repository-scoped Docker runner
|
a Jenkins LTS controller runs beside Gitea on the DigitalOcean droplet,
|
||||||
on Vincent's laptop while Gitea remains on the DigitalOcean droplet. The
|
reachable at \url{https://ci.yebilly.me/login} from approved networks only.
|
||||||
workflow checks out the triggering revision, compiles with a recorded TeX
|
A Gitea pull request triggers a private webhook; Jenkins tests the pull
|
||||||
Live toolchain, adds run and commit identifiers to the PDF version, and
|
request's latest head commit with a versioned \texttt{Jenkinsfile} and
|
||||||
uploads the PDF and build diagnostics. Two successful source-change runs,
|
reports a named status check that branch protection requires before merge.
|
||||||
an intentional compiler failure, and a successful repair demonstrate the
|
A deliberate unit-test failure blocked pull request \#15, a repair passed,
|
||||||
workflow. Earlier chapters retain the group's prior assignment results.
|
and the change was reviewed and merged. Earlier chapters retain the group's
|
||||||
|
prior assignment results, including the Gitea Actions manual build.
|
||||||
|
|||||||
@@ -521,3 +521,110 @@ replace review of the final workflow-generated PDF. No commit, push,
|
|||||||
merge, issue closure, or submission was performed by Codex. Final evidence
|
merge, issue closure, or submission was performed by Codex. Final evidence
|
||||||
update push, successful artifact review, group pull-request review/merge,
|
update push, successful artifact review, group pull-request review/merge,
|
||||||
issue \#12 closure, and submission remain human workflow steps.
|
issue \#12 closure, and submission remain human workflow steps.
|
||||||
|
|
||||||
|
\section{Assignment 6 Jenkins Capacity and Test Preparation}
|
||||||
|
Date: October 19--21, 2026; Tool: OpenAI Codex; Human: Vincent Sun.
|
||||||
|
Inputs: instructor manual version 1.38 supplied by Vincent, the authorized
|
||||||
|
DigitalOcean droplet view, repository instructions, Vincent's reported resize
|
||||||
|
constraint and choice to test the existing droplet, terminal screenshots, and
|
||||||
|
downloaded capacity measurements. Codex prepared isolated core-only experiments;
|
||||||
|
Vincent ran them through his authenticated SSH connection. The first timed out.
|
||||||
|
After Vincent authorized stopping the graded Color Buttons app, the second
|
||||||
|
demonstrated core startup and 24 successful sampled Gitea HTTP checks. No kernel
|
||||||
|
out-of-memory event was recorded; final container accounting nevertheless
|
||||||
|
included about 80\,MiB RAM plus 212\,MiB swap. This is not evidence of plugin or
|
||||||
|
build capacity. Human/AI correction: the raw result claimed a 60-second idle
|
||||||
|
window, but recorded successful HTTP samples span only 54 seconds. Codex
|
||||||
|
preserved the evidence and prepared a corrected, unexecuted core script whose
|
||||||
|
timer starts after a successful response.
|
||||||
|
|
||||||
|
Vincent requested a portable human/Claude handoff for Billy Ye. Codex assembled
|
||||||
|
selected non-secret references, original evidence, scripts, structured state,
|
||||||
|
the prior team PDF and integrity hashes. The instructor PDF was missing at its
|
||||||
|
previous location when packaging; that limitation was identified explicitly.
|
||||||
|
On October 21, Vincent reported school-network connection timeouts. Read-only
|
||||||
|
checks confirmed that the attached Cloud Firewall allowed the measured source
|
||||||
|
IPv4, Gitea HTTPS responded, and TCP 22 timed out. The location/cause of filtering
|
||||||
|
was not proven. No firewall change, reboot or package upgrade was made by Codex.
|
||||||
|
|
||||||
|
Vincent asked Codex to prepare and explain the next test. The versioned test
|
||||||
|
sources include a host-side Python controller, disposable container
|
||||||
|
bootstrap, explicit Pipeline/Gitea plugin requests, plugin archive inventory,
|
||||||
|
trusted initialization hook, sample Python pipeline, fault/regression checks
|
||||||
|
and a readable runbook. The prepared test covers constrained installation,
|
||||||
|
plugin activation, a corrected 60-second healthy observation, then serial
|
||||||
|
passing, intentionally failing and repaired calculation tests. It retains
|
||||||
|
resource and Gitea checks, separate RAM/swap accounting, targeted cleanup and
|
||||||
|
a detached deadline. It adds no production credential, public Jenkins endpoint,
|
||||||
|
webhook, merge check, persistent service or paid resource. The controller's
|
||||||
|
single executor is restricted by the experiment's trusted local fixture; it
|
||||||
|
does not establish the final production build boundary.
|
||||||
|
|
||||||
|
Verification used: nine local Python regression/fault checks passed, including
|
||||||
|
the actual sample application's pass/failure/repair sequence; Git Bash accepted
|
||||||
|
the bootstrap syntax. Official plugin documentation supplied version/baseline
|
||||||
|
checks. Docker was initially off; Vincent then enabled it and authorized local
|
||||||
|
verification. The first local attempt exhausted the installer's 128\,MiB Java
|
||||||
|
heap while reading the plugin catalog, before Jenkins started; Docker did not
|
||||||
|
report a kernel OOM kill. Codex separated laptop-only plugin preparation
|
||||||
|
(768\,MiB RAM, 512\,MiB heap) from runtime. The official installer prepared
|
||||||
|
59 versioned and hashed plugin archives, and its temporary container was removed.
|
||||||
|
|
||||||
|
The revised runtime kept the original limits: 256\,MiB RAM, 512\,MiB for RAM
|
||||||
|
plus swap, half a CPU and a 128\,MiB heap. All 59 plugins loaded; healthy HTTP
|
||||||
|
samples spanned 65.39 seconds before the job ran. Three serial Jenkins builds
|
||||||
|
produced success, the intended unit-test failure, and repaired success. Peak
|
||||||
|
simultaneous accounted RAM plus swap was about 389.5\,MiB, with zero recorded
|
||||||
|
container OOM events. Cleanup succeeded and no experiment containers remained.
|
||||||
|
This demonstrates local Jenkins execution, not capacity beside Gitea on the
|
||||||
|
droplet. The laptop Docker VM had substantially more host resources; local mode
|
||||||
|
recorded the unmeasured droplet host/Gitea fields as null. Original failed and
|
||||||
|
successful evidence was retained. The upload package includes the resolved
|
||||||
|
plugin archives so the droplet need not repeat the larger catalog-resolution
|
||||||
|
step. Remaining work includes the guarded droplet run, actual Gitea integration and
|
||||||
|
merge-gate exercise, and the Assignment 6 report chapter. Hosts and Passwords
|
||||||
|
tables remain unchanged because no persistent service or real integration
|
||||||
|
credential was added. Existing deployment files and evidence were preserved;
|
||||||
|
no commit, push, merge or submission was performed by Codex.
|
||||||
|
|
||||||
|
\section{Assignment 6 Jenkins Deployment, Merge Gate, and Chapter}
|
||||||
|
Date: October 21--23, 2026; Tool: Anthropic Claude Code (Claude Opus 5.5);
|
||||||
|
Human: Billy Ye, with Vincent Sun as reviewer.
|
||||||
|
Inputs: instructor manual version 1.38 (Chapter 4), Vincent's two handoff
|
||||||
|
packages (capacity evidence, the prepared \texttt{ci/jenkins-capacity} test
|
||||||
|
and plugin bundle, and the patch for the preceding record), the repository
|
||||||
|
and its AI guidance, Billy's decisions (Jenkins on the existing droplet,
|
||||||
|
Claude runs droplet commands over SSH with Billy approving each step,
|
||||||
|
browser allowlist of Stevens 155.246.0.0/16 plus team addresses, and the
|
||||||
|
instructor's Python pricing example), and Billy's dated screenshots. Billy
|
||||||
|
loaded his SSH key into the Windows agent and typed its passphrase himself;
|
||||||
|
Claude never saw the passphrase, the Jenkins initial password, any account
|
||||||
|
password, or the \texttt{jenkins-bot} token.
|
||||||
|
|
||||||
|
Claude read the droplet state, ran Vincent's guarded test unchanged
|
||||||
|
(first run aborted on upload permissions it introduced; fixed with
|
||||||
|
\texttt{chmod}; second run passed), wrote the Dockerfile, plugin lockfile,
|
||||||
|
Compose, Caddy, and README changes, deployed Jenkins with a backup and
|
||||||
|
monitored rollout, and pushed the feature commits after Billy asked.
|
||||||
|
Billy performed every web-interface step (DNS, Jenkins setup and security,
|
||||||
|
bot account and token, credential, job, webhook, branch protection, PR
|
||||||
|
creation, merge); Vincent reviewed and approved PR~\#15.
|
||||||
|
|
||||||
|
Human/AI corrections: the plugin installer exhausted a 128\,MiB heap, so
|
||||||
|
Claude replaced it with hashed \texttt{curl} downloads; the 128\,MiB runtime
|
||||||
|
heap hung the web interface, so Claude doubled the container limits with a
|
||||||
|
recorded reason; Claude had dropped \texttt{matrix-auth} when adopting
|
||||||
|
Vincent's bundle, which Billy discovered when the option was missing, and
|
||||||
|
it was added; Billy's question about the build-view screenshot showed no
|
||||||
|
stage view was installed, so \texttt{pipeline-graph-view} was added. Claude
|
||||||
|
redacted a Jenkins reporting-endpoint ID and personal browser details from
|
||||||
|
screenshots.
|
||||||
|
|
||||||
|
Outputs used: the deployment files and application/test/\texttt{Jenkinsfile}
|
||||||
|
in PR~\#15; the command log retained under ignored
|
||||||
|
\texttt{build/evidence/}; \ChapterRef{JenkinsCI}; updated Hosts and Passwords
|
||||||
|
tables; glossary terms; title page, abstract, Document History; this record.
|
||||||
|
Unresolved: three theme plugins installed through the web interface are not
|
||||||
|
in the lockfile; the course deadline was reported as Friday but not checked
|
||||||
|
on the course page by Claude; the final PDF needs the Gitea Actions runner
|
||||||
|
on Vincent's laptop. No submission was performed by Claude.
|
||||||
|
|||||||
@@ -34,16 +34,16 @@
|
|||||||
\definecolor{devopsLightBlue}{RGB}{232,240,247}
|
\definecolor{devopsLightBlue}{RGB}{232,240,247}
|
||||||
|
|
||||||
% Replace these values for each assignment.
|
% Replace these values for each assignment.
|
||||||
\newcommand{\AssignmentTitle}{LaTeX Auto-Compilation with Gitea -- Group}
|
\newcommand{\AssignmentTitle}{Gitea + Jenkins Autobuild and Testing -- Group}
|
||||||
\newcommand{\AssignmentNumber}{5}
|
\newcommand{\AssignmentNumber}{6}
|
||||||
\newcommand{\DocumentVersion}{3.4}
|
\newcommand{\DocumentVersion}{4.0}
|
||||||
\newcommand{\DocumentStatus}{Draft}
|
\newcommand{\DocumentStatus}{Draft}
|
||||||
\newcommand{\CourseNumber}{SSW 590}
|
\newcommand{\CourseNumber}{SSW 590}
|
||||||
\newcommand{\CourseName}{DevOps}
|
\newcommand{\CourseName}{DevOps}
|
||||||
\newcommand{\Authors}{Vincent Sun and Billy Ye}
|
\newcommand{\Authors}{Vincent Sun and Billy Ye}
|
||||||
\newcommand{\Organization}{Stevens Institute of Technology}
|
\newcommand{\Organization}{Stevens Institute of Technology}
|
||||||
\newcommand{\DocumentDate}{10/7/2026}
|
\newcommand{\DocumentDate}{10/22/2026}
|
||||||
\newcommand{\DueDate}{Wednesday by 11:59pm}
|
\newcommand{\DueDate}{Friday by 11:59pm}
|
||||||
% CI writes this ignored file in its checkout; ordinary local builds stay unchanged.
|
% CI writes this ignored file in its checkout; ordinary local builds stay unchanged.
|
||||||
\providecommand{\CIBuildSuffix}{}
|
\providecommand{\CIBuildSuffix}{}
|
||||||
\InputIfFileExists{ci-build-metadata.tex}{}{}
|
\InputIfFileExists{ci-build-metadata.tex}{}{}
|
||||||
@@ -146,6 +146,7 @@
|
|||||||
\include{devopsProjectProposal}
|
\include{devopsProjectProposal}
|
||||||
\include{devopsGitea}
|
\include{devopsGitea}
|
||||||
\include{devopsAutomatedManualBuild}
|
\include{devopsAutomatedManualBuild}
|
||||||
|
\include{devopsJenkins}
|
||||||
\include{devopsHostsPasswords}
|
\include{devopsHostsPasswords}
|
||||||
|
|
||||||
% Restore when a chapter cites devopsReferences.bib.
|
% Restore when a chapter cites devopsReferences.bib.
|
||||||
|
|||||||
@@ -346,4 +346,11 @@ review the resulting successful workflow PDF and retain that final artifact
|
|||||||
for submission. Pull-request review/merge and issue \#12 closure are still
|
for submission. Pull-request review/merge and issue \#12 closure are still
|
||||||
pending; no approval or submission is claimed here.
|
pending; no approval or submission is claimed here.
|
||||||
|
|
||||||
|
\textbf{Status update, October 22, 2026:} the pending steps above have since
|
||||||
|
completed.
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/13}{PR~\#13}
|
||||||
|
was merged and issue \#12 is closed (re-checked in Gitea on October 22), and
|
||||||
|
the merged-\texttt{main} workflow run~6 passed (verified by Vincent on
|
||||||
|
October 21). The paragraph above is kept as the version 3.4 record.
|
||||||
|
|
||||||
\endgroup
|
\endgroup
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ link each entry to the changed chapter, table, figure, or controlled artifact.
|
|||||||
\multicolumn{4}{l}{\small\itshape Document Update History (continued)}\\
|
\multicolumn{4}{l}{\small\itshape Document Update History (continued)}\\
|
||||||
\toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule
|
\toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule
|
||||||
\endhead \bottomrule \endlastfoot
|
\endhead \bottomrule \endlastfoot
|
||||||
|
October 22--23, 2026 / 4.0 & BY, VS, Claude & Assignment 6: ran the guarded Jenkins capacity test on the resized 1\,GiB droplet; deployed Jenkins 2.580.1 LTS with a hashed plugin lockfile behind Caddy at \texttt{ci.yebilly.me} (Stevens and team allowlist); integrated Gitea via a private webhook and the \texttt{jenkins-bot} identity; required check \texttt{vpn-dns-gateway/pipeline/pr-main} on \texttt{main}; recorded PR~\#15's pass, blocked failure, repair, review, and merge, the restart-persistence and IPv4/IPv6 exposure tests, and the plugin-update check. \textbf{Updated the Hosts table} (resize, Jenkins, \texttt{ci} DNS, Color Buttons retired) and \textbf{the Passwords table} (Jenkins administrators, \texttt{jenkins-bot} account and token, CI allowlist file). Added glossary terms, set the Assignment 6 title page and abstract, and noted the completed Assignment 5 merge. & Title and abstract, \ChapterRef{JenkinsCI}, \ChapterRef{HostsPasswords}, \ChapterRef{AutomatedManualBuild}, \ChapterRef{AIPromptLog}\\
|
||||||
|
October 21, 2026 / preparation & VS, Codex & Recorded core-test timing qualification and the Billy/Claude handoff; prepared the plugin/pipeline test and verified it locally after separating plugin resolution from runtime. The droplet run remains unverified. Hosts and Passwords tables are unchanged because no persistent Jenkins service or real integration credential was added. & \ChapterRef{AIPromptLog}\\
|
||||||
October 7, 2026 / 3.4 & VS, Codex & Added the successful run-4 repair screenshots and verified its commit, PDF version, artifact contents, and SHA-256; completed the failure/repair evidence. Replaced the abstract's template instructions with an Assignment 5 summary. Hosts and Passwords tables are unchanged from 3.3; final workflow PDF review and submission remain pending. & Title and abstract, \ChapterRef{AutomatedManualBuild}, \ChapterRef{AIPromptLog}\\
|
October 7, 2026 / 3.4 & VS, Codex & Added the successful run-4 repair screenshots and verified its commit, PDF version, artifact contents, and SHA-256; completed the failure/repair evidence. Replaced the abstract's template instructions with an Assignment 5 summary. Hosts and Passwords tables are unchanged from 3.3; final workflow PDF review and submission remain pending. & Title and abstract, \ChapterRef{AutomatedManualBuild}, \ChapterRef{AIPromptLog}\\
|
||||||
October 7, 2026 / 3.3 & VS, Codex & Recorded successful run 2 and intentional failure run 3 with screenshots and downloaded diagnostic verification; removed the test error for a repair push. Updated both the Hosts section and hints-only Passwords table for the local runner; passing repair evidence and final artifact review remain pending. & \ChapterRef{AutomatedManualBuild}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\
|
October 7, 2026 / 3.3 & VS, Codex & Recorded successful run 2 and intentional failure run 3 with screenshots and downloaded diagnostic verification; removed the test error for a repair push. Updated both the Hosts section and hints-only Passwords table for the local runner; passing repair evidence and final artifact review remain pending. & \ChapterRef{AutomatedManualBuild}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\
|
||||||
October 7, 2026 / 3.2 & VS, Codex & Set the Assignment 5 title, number, and date after successful Gitea run 1; retained its original PDF and evidence. The new title omits the duplicate LMS suffix. Added the draft Automated Manual Build chapter with the workflow and first-PDF screenshots. Hosts and Passwords tables are unchanged; remaining workflow tests and runner records are pending. & Title page, \ChapterRef{AutomatedManualBuild}, \ChapterRef{AIPromptLog}\\
|
October 7, 2026 / 3.2 & VS, Codex & Set the Assignment 5 title, number, and date after successful Gitea run 1; retained its original PDF and evidence. The new title omits the duplicate LMS suffix. Added the draft Automated Manual Build chapter with the workflow and first-PDF screenshots. Hosts and Passwords tables are unchanged; remaining workflow tests and runner records are pending. & Title page, \ChapterRef{AutomatedManualBuild}, \ChapterRef{AIPromptLog}\\
|
||||||
|
|||||||
@@ -23,3 +23,10 @@
|
|||||||
|
|
||||||
\newglossaryentry{build-runner}{name={build runner},description={A registered worker that receives workflow jobs and executes them in its configured environment}}
|
\newglossaryentry{build-runner}{name={build runner},description={A registered worker that receives workflow jobs and executes them in its configured environment}}
|
||||||
\newglossaryentry{build-artifact}{name={build artifact},description={A file retained by a workflow run for download, such as a compiled PDF or diagnostic log; retention may be limited}}
|
\newglossaryentry{build-artifact}{name={build artifact},description={A file retained by a workflow run for download, such as a compiled PDF or diagnostic log; retention may be limited}}
|
||||||
|
|
||||||
|
\newglossaryentry{webhook}{name={webhook},description={An HTTP request that one service sends automatically to another when an event occurs, such as Gitea notifying Jenkins of a push or pull-request update}}
|
||||||
|
\newglossaryentry{status-check}{name={status check},description={A named pass/fail result that a CI system attaches to a commit through the Git server's commit-status API; Gitea shows it on pull requests}}
|
||||||
|
\newglossaryentry{branch-protection}{name={branch protection},description={Repository rules on a branch, such as disallowing direct pushes and requiring status checks and approvals before a pull request can merge}}
|
||||||
|
\newglossaryentry{jenkinsfile}{name={Jenkinsfile},description={A version-controlled file at the repository root that defines a Jenkins pipeline's stages and steps}}
|
||||||
|
\newglossaryentry{controller}{name={controller},description={The central Jenkins server that serves the web interface, stores configuration, and schedules builds; it can also run builds on its own executors}}
|
||||||
|
\newglossaryentry{build-agent}{name={build agent},description={A separate machine or container that connects to a Jenkins controller and runs builds, isolating build code from the controller}}
|
||||||
|
|||||||
@@ -10,33 +10,44 @@ password, token, recovery code, or private key. Distinct services use distinct
|
|||||||
credentials, which are stored outside this manual and outside every
|
credentials, which are stored outside this manual and outside every
|
||||||
repository. Both tables were created on 28 September 2026 for Assignment 4
|
repository. Both tables were created on 28 September 2026 for Assignment 4
|
||||||
(\ChapterRef{GiteaFoundation}). The local runner host and its identity hint
|
(\ChapterRef{GiteaFoundation}). The local runner host and its identity hint
|
||||||
were added on October 7, 2026 for \ChapterRef{AutomatedManualBuild}.
|
were added on October 7, 2026 for \ChapterRef{AutomatedManualBuild}. On
|
||||||
|
October 22--23, 2026 (\ChapterRef{JenkinsCI}) the droplet record was updated
|
||||||
|
for the 1\,GiB resize, the Jenkins service, and \texttt{ci.yebilly.me}; the
|
||||||
|
Color Buttons app was marked retired; and the Passwords table gained the
|
||||||
|
Jenkins administrators, the \texttt{jenkins-bot} Gitea account, and its token.
|
||||||
|
|
||||||
\section{Hosts}
|
\section{Hosts}
|
||||||
\small
|
\small
|
||||||
\begin{tabularx}{\linewidth}{@{}L{3.3cm}Y@{}}
|
\begin{tabularx}{\linewidth}{@{}L{3.3cm}Y@{}}
|
||||||
\caption{Hosts\label{Table:Hosts}}\\
|
\caption{Hosts\label{Table:Hosts}}\\
|
||||||
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, colors.yebilly.me)}\\ \midrule
|
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, ci.yebilly.me)}\\ \midrule
|
||||||
\endfirsthead
|
\endfirsthead
|
||||||
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, colors.yebilly.me)}\\ \midrule
|
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, ci.yebilly.me)}\\ \midrule
|
||||||
\endhead
|
\endhead
|
||||||
\bottomrule \endlastfoot
|
\bottomrule \endlastfoot
|
||||||
Role & Gitea work hub (Gitea 1.27.3 behind Caddy 2.11.4 TLS proxy); since
|
Role & Gitea work hub (Gitea 1.27.3 behind Caddy 2.11.4 TLS proxy); since
|
||||||
29 Sep 2026 also the Assignment 3 Color Buttons site\\
|
22 Oct 2026 also the Jenkins 2.580.1 LTS controller, which runs the CI builds.
|
||||||
|
The Assignment 3 Color Buttons app (29 Sep 2026) is retired: container
|
||||||
|
stopped with restart policy \texttt{no}; its Caddy route remains\\
|
||||||
Environment & Course production (team use)\\
|
Environment & Course production (team use)\\
|
||||||
Provider & DigitalOcean, NYC1; Ubuntu 24.04 LTS; 1 vCPU, 512\,MB RAM, 10\,GB disk\\
|
Provider & DigitalOcean, NYC1; Ubuntu 24.04 LTS; 1 vCPU; resized from
|
||||||
|
512\,MB to the 1\,GiB Basic plan in October 2026 (961\,MiB reported, 25\,GB
|
||||||
|
plan disk, 1\,GiB swap file)\\
|
||||||
Public address / DNS & IPv4 \texttt{147.182.178.136}; \texttt{A} records
|
Public address / DNS & IPv4 \texttt{147.182.178.136}; \texttt{A} records
|
||||||
\texttt{git.yebilly.me} and \texttt{colors.yebilly.me}; public IPv6 assigned
|
\texttt{git}, \texttt{ci}, and \texttt{colors} \texttt{.yebilly.me}; public
|
||||||
but not published in DNS\\
|
IPv6 \texttt{2604:a880:400:d1:0:5:22d:6001} assigned but not published in DNS\\
|
||||||
Private services & Gitea \texttt{:3000} and \texttt{color-buttons-app}
|
Private services & Gitea \texttt{:3000} and Jenkins \texttt{:8080} (512\,MiB
|
||||||
\texttt{:3000} (96\,MiB memory cap) on Docker network \texttt{gitea\_web}, no
|
RAM, 0.75 CPU cap; agent port disabled) on Docker network \texttt{gitea\_web},
|
||||||
host ports; SQLite file in volume \texttt{gitea\_gitea-data}\\
|
no host ports; SQLite file in volume \texttt{gitea\_gitea-data}; Jenkins state
|
||||||
|
in volume \texttt{gitea\_jenkins-home}\\
|
||||||
Exposed ports & 443/TCP and 80/TCP to all; 22/TCP to approved team addresses only
|
Exposed ports & 443/TCP and 80/TCP to all; 22/TCP to approved team addresses only
|
||||||
(Cloud Firewall \texttt{gitea-fw})\\
|
(Cloud Firewall \texttt{gitea-fw}); \texttt{ci.yebilly.me} answers only
|
||||||
|
Stevens 155.246.0.0/16 and team addresses (Caddy allowlist), 403 otherwise\\
|
||||||
Owner & BY (server administration); VS (review)\\
|
Owner & BY (server administration); VS (review)\\
|
||||||
HTTPS URLs & \url{https://git.yebilly.me}, \url{https://colors.yebilly.me}\\
|
HTTPS URLs & \url{https://git.yebilly.me}, \url{https://ci.yebilly.me/login}\\
|
||||||
Backup status & No backup job; container-replacement persistence verified only
|
Backup status & No backup job; container-replacement persistence verified for
|
||||||
(\ChapterRef{GiteaFoundation})\\
|
Gitea (\ChapterRef{GiteaFoundation}) and restart persistence for Jenkins
|
||||||
|
(\ChapterRef{JenkinsCI}) only\\
|
||||||
Monitoring status & No alerting configured; checked manually with
|
Monitoring status & No alerting configured; checked manually with
|
||||||
\texttt{docker compose ps}, \texttt{docker stats}, and logs\\
|
\texttt{docker compose ps}, \texttt{docker stats}, and logs\\
|
||||||
\end{tabularx}
|
\end{tabularx}
|
||||||
@@ -74,6 +85,12 @@ Monitoring / backup & Runner logs and Gitea Actions checked manually; no automat
|
|||||||
Gitea local runner identity & VS & Docker volume \texttt{ssw590-local-runner-data}, file \texttt{/data/.runner}; generated identity, no values in Git; registration token supplied privately from repository settings & Repository runner; Docker control on VS laptop\\
|
Gitea local runner identity & VS & Docker volume \texttt{ssw590-local-runner-data}, file \texttt{/data/.runner}; generated identity, no values in Git; registration token supplied privately from repository settings & Repository runner; Docker control on VS laptop\\
|
||||||
Gitea \texttt{bill} & BY & BY's password manager & Site administrator\\
|
Gitea \texttt{bill} & BY & BY's password manager & Site administrator\\
|
||||||
Gitea \texttt{vsun1} & VS & VS's password manager & Repository administrator\\
|
Gitea \texttt{vsun1} & VS & VS's password manager & Repository administrator\\
|
||||||
|
Gitea \texttt{jenkins-bot} (added 22 Oct 2026) & BY & BY's password manager; used only to create its token & Write collaborator on \texttt{vpn-dns-gateway}\\
|
||||||
|
\texttt{jenkins-bot} token \texttt{jenkins-ci} & BY & Jenkins credential ID \texttt{gitea-jenkins-bot} (System, Global), encrypted in volume \texttt{gitea\_jenkins-home}; revoke under the bot's Gitea Applications settings & Repository read/write; organization and user read\\
|
||||||
|
Jenkins \texttt{billy} & BY & BY's password manager & Administer (all)\\
|
||||||
|
Jenkins \texttt{vsun1} & VS & VS's password manager & Administer (all)\\
|
||||||
|
Jenkins initial admin password & --- & One-time setup secret in \texttt{/var/jenkins\_home/secrets/}; read once by BY, superseded by named accounts & Setup only\\
|
||||||
|
CI allowlist \texttt{.env} & BY & \texttt{\textasciitilde/gitea/.env} on the droplet, root-only; holds team IP addresses (personal data, not a secret) & n/a\\
|
||||||
DigitalOcean team & BY, VS & Each member's own login, in their password manager & Team member\\
|
DigitalOcean team & BY, VS & Each member's own login, in their password manager & Team member\\
|
||||||
Namecheap (\texttt{yebilly.me}) & BY & BY's password manager & Domain owner\\
|
Namecheap (\texttt{yebilly.me}) & BY & BY's password manager & Domain owner\\
|
||||||
Droplet \texttt{root} SSH & BY & Key-based only; private key \texttt{digiOcean} on BY's laptop; no password login & Root\\
|
Droplet \texttt{root} SSH & BY & Key-based only; private key \texttt{digiOcean} on BY's laptop; no password login & Root\\
|
||||||
|
|||||||
@@ -0,0 +1,613 @@
|
|||||||
|
\chapter{Continuous Integration with Jenkins}
|
||||||
|
\ChapterLabel{JenkinsCI}
|
||||||
|
\index{Jenkins}
|
||||||
|
\index{Jenkins!merge gate}
|
||||||
|
\index{Gitea!required status check}
|
||||||
|
\begingroup
|
||||||
|
\sloppy
|
||||||
|
|
||||||
|
This chapter records Assignment 6, \emph{Gitea + Jenkins Autobuild and
|
||||||
|
Testing -- Group} (instructor manual version 1.38, Chapter 4). Jenkins now runs
|
||||||
|
beside Gitea on the droplet \texttt{The-Ocean}. A pull request (PR) to
|
||||||
|
\texttt{main} in the
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway}{Group 1 Gitea
|
||||||
|
repository} triggers a Jenkins pipeline through a private \gls{webhook}.
|
||||||
|
Jenkins tests the PR's latest head commit and reports a named
|
||||||
|
\gls{status-check} to Gitea; \gls{branch-protection} on \texttt{main} blocks
|
||||||
|
the merge until that check passes and a teammate approves. The work was
|
||||||
|
carried out on October 21--23, 2026 (times below are UTC unless marked
|
||||||
|
Eastern). Sections~\ref{Section:JenkinsDeployment}--\ref{Section:JenkinsQuality}
|
||||||
|
follow the eight rubric rows in order.
|
||||||
|
|
||||||
|
\begin{devopsNote}[Result summary]
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/15}{PR~\#15}
|
||||||
|
(closes
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/issues/14}{issue~\#14})
|
||||||
|
passed on its first commit, was blocked by a deliberate unit-test failure,
|
||||||
|
passed again after the repair, was approved by Vincent, and was merged as
|
||||||
|
\texttt{420ba4c}. Jenkins checked out the exact PR head for every run, and
|
||||||
|
the commit IDs match across Gitea and Jenkins (Table~\ref{Table:JenkinsSequence}).
|
||||||
|
\end{devopsNote}
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{Jenkins Deployment and Persistence}
|
||||||
|
\label{Section:JenkinsDeployment}
|
||||||
|
\index{Jenkins!deployment}
|
||||||
|
|
||||||
|
\paragraph{Image and plugins.}
|
||||||
|
Jenkins uses the official long-term-support (LTS) image
|
||||||
|
\texttt{jenkins/jenkins:2.580.1-lts-jdk21}, pinned by digest
|
||||||
|
\texttt{sha256:a660310e\ldots82c1}.\footnote{\url{https://www.jenkins.io/doc/book/installing/docker/}}
|
||||||
|
The versioned
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/deploy/jenkins/Dockerfile}{\texttt{deploy/jenkins/Dockerfile}}
|
||||||
|
adds only \texttt{python3} (Python 3.13.5; Git 2.47.3 is already in the
|
||||||
|
image) because builds run on the controller. Plugins come from the lockfile
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/deploy/jenkins/plugins.txt}{\texttt{deploy/jenkins/plugins.txt}},
|
||||||
|
which pins every plugin's version and SHA-256. The image build downloads each
|
||||||
|
archive and verifies its hash. Table~\ref{Table:JenkinsPlugins} lists the
|
||||||
|
plugins the pipeline relies on; the full lockfile holds 63 plugins including
|
||||||
|
dependencies.
|
||||||
|
|
||||||
|
\begin{table}[H]
|
||||||
|
\centering\footnotesize
|
||||||
|
\caption{Principal Jenkins plugins (core 2.580.1)\label{Table:JenkinsPlugins}}
|
||||||
|
\begin{tabular}{@{}L{4.4cm}L{4.4cm}L{6.0cm}@{}}
|
||||||
|
\toprule \textbf{Plugin} & \textbf{Version} & \textbf{Purpose}\\ \midrule
|
||||||
|
\texttt{gitea} & \texttt{286.v0740a\_413c1eb\_} & Gitea SCM source, webhook receiver, commit status\\
|
||||||
|
\texttt{workflow-aggregator} & \texttt{608.v67378e9d3db\_1} & Pipeline suite\\
|
||||||
|
\texttt{pipeline-model-definition} & \texttt{2.2293.v6e7193cec599} & Declarative \texttt{Jenkinsfile} syntax\\
|
||||||
|
\texttt{workflow-multibranch} & \texttt{842.v3a\_b\_59b\_57b\_e6e} & One job per branch / PR\\
|
||||||
|
\texttt{git} & \texttt{5.11.0} & Checkout of the selected revision\\
|
||||||
|
\texttt{matrix-auth} & \texttt{3.3} & Named user permissions\\
|
||||||
|
\texttt{pipeline-graph-view} & \texttt{1053.v9df19e6ceed2} & Stage view of each run\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabular}
|
||||||
|
\end{table}
|
||||||
|
|
||||||
|
\paragraph{Capacity preparation.}
|
||||||
|
The droplet originally had 512\,MB RAM. Vincent's October 19 core-only
|
||||||
|
experiments started Jenkins but pushed about 212\,MiB into swap, and their
|
||||||
|
recorded idle window was only 54 seconds of successful samples (see the
|
||||||
|
October 21 record in \ChapterRef{AIPromptLog}). Before this deployment the team
|
||||||
|
resized \texttt{The-Ocean} to the 1\,GiB Basic plan (Linux reports 961\,MiB RAM,
|
||||||
|
24\,GB disk, 1\,GiB swap file). On October 22 Billy ran Vincent's guarded
|
||||||
|
plugin and pipeline test, \texttt{ci/jenkins-capacity/run\_test.py}, unchanged
|
||||||
|
on the droplet:
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.6cm}Y}
|
||||||
|
\caption{Guarded capacity test on The-Ocean, October 22, 2026\label{Table:JenkinsCapacity}}\\
|
||||||
|
\toprule \textbf{Record} & \textbf{Observed value}\\ \midrule
|
||||||
|
Run 1 (03:02--03:04) & Aborted: \texttt{java.io.FileNotFoundException}. All 59
|
||||||
|
plugins were active; Gitea returned 200 throughout. Cause: Windows
|
||||||
|
\texttt{scp} uploaded the test folders as root-only, so the container's
|
||||||
|
\texttt{jenkins} user could not read its fixtures. Fixed with
|
||||||
|
\texttt{chmod -R u=rwX,go=rX}; the script was not changed.\\
|
||||||
|
Run 2 (03:05--03:09) & \StatusPass: 59 plugins active, 60.6\,s healthy
|
||||||
|
idle, builds SUCCESS / FAILURE (\texttt{13 != 30}) / SUCCESS\\
|
||||||
|
Peak container memory & 252.8\,MiB RAM, 147.1\,MiB swap (393.9\,MiB together); no OOM events\\
|
||||||
|
Host minimum & 238\,MiB available RAM, 824\,MiB free swap; Gitea 200 on all 30 samples\\
|
||||||
|
CPU & Throttled in 1,689 of 2,212 periods at the 0.5-CPU limit\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\paragraph{Compose service.}
|
||||||
|
Jenkins is a third service in the existing
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/deploy/docker-compose.yml}{\texttt{deploy/docker-compose.yml}}
|
||||||
|
(redacted excerpt; no secrets exist in the file):
|
||||||
|
\begin{minted}{yaml}
|
||||||
|
jenkins:
|
||||||
|
build: ./jenkins
|
||||||
|
image: ssw590-jenkins:2.580.1
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- JAVA_OPTS=-Xms64m -Xmx256m -XX:+UseSerialGC -Djava.awt.headless=true
|
||||||
|
volumes:
|
||||||
|
- jenkins-home:/var/jenkins_home
|
||||||
|
networks: [web]
|
||||||
|
mem_limit: 512m
|
||||||
|
memswap_limit: 768m
|
||||||
|
cpus: 0.75
|
||||||
|
pids_limit: 256
|
||||||
|
# no ports: Caddy and the Gitea webhook reach jenkins:8080 privately
|
||||||
|
\end{minted}
|
||||||
|
The first deployment kept the test's limits (256\,MiB RAM, 128\,MiB heap,
|
||||||
|
0.5 CPU). Builds worked, but the setup wizard and plugin pages hung with
|
||||||
|
\texttt{OutOfMemoryError: Java heap space} once Jenkins loaded the
|
||||||
|
update-center catalog. The limits were doubled to those shown above at
|
||||||
|
03:35; Jenkins then answered in 45\,s instead of 184\,s, used about
|
||||||
|
350\,MiB, and left about 180\,MiB of host RAM available with Gitea still
|
||||||
|
returning 200. The service runs one executor so only one build uses memory
|
||||||
|
at a time.
|
||||||
|
|
||||||
|
\paragraph{Persistent state and restart test.}
|
||||||
|
Configuration, users, credentials, jobs, and build history live in the
|
||||||
|
\gls{named-volume} \texttt{gitea\_jenkins-home} mounted at
|
||||||
|
\texttt{/var/jenkins\_home}; the restart policy is \texttt{unless-stopped}.
|
||||||
|
On October 23, after the merge, Billy's session restarted the container and
|
||||||
|
compared state before and after:
|
||||||
|
\begin{minted}{text}
|
||||||
|
== BEFORE 2026-10-23T00:56:21Z started=2026-10-22T03:46:07Z
|
||||||
|
PR-15 builds=3 feature-issue-14 builds=1 main builds=1 users: billy vsun1
|
||||||
|
de35139e5c1d2510 de1a292f55d3050a e0e1e971a6f7e1c4 36bb5fd38ecf7ac6
|
||||||
|
== AFTER 2026-10-23T00:57:07Z (login 200 after ~25s) restart=unless-stopped
|
||||||
|
PR-15 builds=3 feature-issue-14 builds=1 main builds=1 users: billy vsun1
|
||||||
|
de35139e5c1d2510 de1a292f55d3050a e0e1e971a6f7e1c4 36bb5fd38ecf7ac6
|
||||||
|
IDENTICAL: jobs, builds, users, config hashes
|
||||||
|
\end{minted}
|
||||||
|
The four hashes are \texttt{config.xml}, \texttt{credentials.xml}, the Gitea
|
||||||
|
server configuration, and the job configuration. Gitea returned 200
|
||||||
|
throughout. \textbf{Restart persistence is not a backup test}: the volume
|
||||||
|
survives a container restart or replacement, but no copy of it exists
|
||||||
|
elsewhere, so losing the droplet or volume would lose Jenkins' state.
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{HTTPS, Access, and Firewall}
|
||||||
|
\label{Section:JenkinsAccess}
|
||||||
|
\index{Jenkins!HTTPS access}
|
||||||
|
|
||||||
|
\paragraph{Login URL and approved access path.}
|
||||||
|
The Jenkins login page is
|
||||||
|
\textbf{\url{https://ci.yebilly.me/login}}. Caddy serves it only to the Stevens
|
||||||
|
network (155.246.0.0/16, registered to Stevens Institute of Technology in
|
||||||
|
ARIN) and the team's dorm address; every other source receives HTTP 403
|
||||||
|
before reaching Jenkins. \textbf{Instructor access:} open the URL from the
|
||||||
|
Stevens campus network or while connected to the Stevens VPN. No sign-in is
|
||||||
|
needed to see the login page, and no grader account exists. This confirms
|
||||||
|
web-service availability only, not that a pipeline works.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{images/jenkins-login-2026-10-21.png}
|
||||||
|
\caption{October 21, 2026, 11:40 p.m.\ Eastern: the Jenkins sign-in page at
|
||||||
|
\texttt{ci.yebilly.me/login} over HTTPS from the team's allowlisted address.
|
||||||
|
Bookmarks and taskbar applications are blurred.}
|
||||||
|
\label{Figure:JenkinsLogin}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\paragraph{DNS, certificate, and redirect.}
|
||||||
|
Billy added an \texttt{A} record \texttt{ci} $\rightarrow$
|
||||||
|
\texttt{147.182.178.136} at Namecheap (Figure~\ref{Figure:JenkinsDNS}). No
|
||||||
|
\texttt{AAAA} record is published for \texttt{ci}. Caddy obtained the
|
||||||
|
certificate automatically at 03:17:31 on October 22 and renews it without a
|
||||||
|
cron job; its renewal window, reported by the certificate authority, is
|
||||||
|
December 20--22, 2026.\footnote{\url{https://caddyserver.com/docs/automatic-https}}
|
||||||
|
The \texttt{ci.yebilly.me} block in
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/deploy/Caddyfile}{\texttt{deploy/Caddyfile}} is:
|
||||||
|
\begin{minted}{text}
|
||||||
|
ci.yebilly.me {
|
||||||
|
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS}
|
||||||
|
respond @denied 403
|
||||||
|
reverse_proxy jenkins:8080
|
||||||
|
}
|
||||||
|
\end{minted}
|
||||||
|
\texttt{CI\_TEAM\_IPS} is read from the untracked, root-only
|
||||||
|
\texttt{\textasciitilde/gitea/.env}, so home addresses are not in Git. Caddy's
|
||||||
|
\texttt{reverse\_proxy} forwards the \texttt{X-Forwarded-*} headers, and the
|
||||||
|
Jenkins URL is set to \texttt{https://ci.yebilly.me/}.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{images/jenkins-dns-namecheap.png}
|
||||||
|
\caption{October 22, 2026: Namecheap Advanced DNS for \texttt{yebilly.me},
|
||||||
|
including the new \texttt{ci} \texttt{A} record to the droplet.}
|
||||||
|
\label{Figure:JenkinsDNS}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\paragraph{External checks.}
|
||||||
|
All tests ran from Billy's laptop, outside the droplet
|
||||||
|
(Table~\ref{Table:JenkinsExposure}). The IPv6 tests target the droplet's
|
||||||
|
IPv6 address directly because IPv6 is enabled on the droplet, even though DNS
|
||||||
|
publishes only IPv4. The laptop's IPv6 address is not on the allowlist, so
|
||||||
|
the IPv6 HTTPS test is also the non-approved-source test.
|
||||||
|
|
||||||
|
{\small
|
||||||
|
\begin{tabularx}{\linewidth}{L{4.0cm}L{3.0cm}L{1.6cm}Y}
|
||||||
|
\caption{External exposure tests\label{Table:JenkinsExposure}}\\
|
||||||
|
\toprule \textbf{Test} & \textbf{Source / time} & \textbf{Expected} & \textbf{Actual}\\ \midrule
|
||||||
|
HTTPS \texttt{ci\ldots/login} & IPv4, allowlisted; Oct 22 03:17:56 & 200 & 200, ``Sign in -- Jenkins'' \StatusPass\\
|
||||||
|
HTTP \texttt{ci\ldots/login} & same & redirect & 308 to \texttt{https://\ldots/login} \StatusPass\\
|
||||||
|
Certificate & same & valid & Let's Encrypt \texttt{YE2}, CN \texttt{ci.yebilly.me}, Oct 22, 2026 -- Jan 20, 2027 \StatusPass\\
|
||||||
|
TCP 8080, 50000 & same & closed & closed/filtered \StatusPass\\
|
||||||
|
TCP 3000 (Gitea backend) & IPv4; Oct 23 01:02 & closed & closed/filtered \StatusPass\\
|
||||||
|
HTTPS \texttt{ci} via droplet IPv6 & IPv6, not allowlisted; Oct 23 01:02:42 & 403 & 403 \StatusPass\\
|
||||||
|
HTTP \texttt{ci} via IPv6 & same & redirect & 308 \StatusPass\\
|
||||||
|
TCP 8080, 50000, 3000 via IPv6 & same & closed & closed/filtered \StatusPass\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}}
|
||||||
|
|
||||||
|
\paragraph{Firewalls and port mappings.}
|
||||||
|
The DigitalOcean \gls{cloud-firewall} \texttt{gitea-fw} is unchanged from
|
||||||
|
Assignment 4 (Figure~\ref{fig:gitea-fw-rules} in \ChapterRef{GiteaFoundation}):
|
||||||
|
TCP 80 and 443 from all IPv4/IPv6, TCP 22 from approved team addresses only.
|
||||||
|
No rule was added for Jenkins, because Jenkins publishes no port. The host
|
||||||
|
firewall (\texttt{ufw}) is inactive; exposure is controlled by the Cloud
|
||||||
|
Firewall and by Compose publishing nothing except Caddy's ports. On the
|
||||||
|
droplet, October 23:
|
||||||
|
\begin{minted}{text}
|
||||||
|
caddy caddy:2.11.4-alpine 0.0.0.0:80->80/tcp, [::]:80->80/tcp, 0.0.0.0:443->443/tcp, [::]:443->443/tcp
|
||||||
|
gitea gitea/gitea:1.27.3 22/tcp, 3000/tcp (not published)
|
||||||
|
jenkins ssw590-jenkins:2.580.1 8080/tcp, 50000/tcp (not published)
|
||||||
|
\end{minted}
|
||||||
|
The inbound agent port is also disabled in Jenkins' security settings
|
||||||
|
(\texttt{slaveAgentPort=-1}).
|
||||||
|
|
||||||
|
\paragraph{Accounts and roles.}
|
||||||
|
Jenkins uses its own user database with sign-up disabled and matrix-based
|
||||||
|
authorization (Figure~\ref{Figure:JenkinsMatrix}). \texttt{billy} (Billy Ye)
|
||||||
|
and \texttt{vsun1} (Vincent Sun) each hold \emph{Overall/Administer};
|
||||||
|
\emph{Anonymous} and \emph{Authenticated Users} hold nothing.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{images/jenkins-security-matrix-2026-10-21.png}
|
||||||
|
\caption{October 21, 2026, 11:50 p.m.\ Eastern: Jenkins security with own
|
||||||
|
user database, sign-up disabled, and matrix authorization granting
|
||||||
|
\emph{Administer} only to the two named team accounts.}
|
||||||
|
\label{Figure:JenkinsMatrix}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{Gitea Trigger and Traceability}
|
||||||
|
\label{Section:JenkinsTrigger}
|
||||||
|
\index{webhook}
|
||||||
|
|
||||||
|
Figure~\ref{Figure:JenkinsDeployment} adapts the instructor's reference
|
||||||
|
deployment to what was built. The browser path and the webhook path are
|
||||||
|
separate: browsers reach Jenkins only through the firewall and Caddy's
|
||||||
|
allowlist, while the webhook, checkout, and status calls never leave the
|
||||||
|
droplet.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\resizebox{\linewidth}{!}{%
|
||||||
|
\begin{tikzpicture}[
|
||||||
|
box/.style={draw, rounded corners, align=center, font=\small, minimum height=1.0cm},
|
||||||
|
lbl/.style={font=\scriptsize, fill=white, inner sep=1pt},
|
||||||
|
arr/.style={-{Stealth}, thick}]
|
||||||
|
\node[box] (browser) at (0,0) {Team / instructor\\browser};
|
||||||
|
\node[box, fill=devopsLightBlue] (fw) at (4.3,0) {Cloud Firewall\\\texttt{gitea-fw}\\443 / 80};
|
||||||
|
\node[box] (caddy) at (8.6,0) {Caddy TLS proxy\\allowlist for \texttt{ci}\\alias \texttt{git.yebilly.me}};
|
||||||
|
\node[box] (gitea) at (13.2,1.9) {Gitea \texttt{:3000}};
|
||||||
|
\node[box] (jenkins) at (13.2,-1.9) {Jenkins controller \texttt{:8080}\\\textbf{builds run here}\\(1 executor)};
|
||||||
|
\node[box] (gvol) at (17.4,1.9) {\texttt{gitea-data}\\SQLite + repos};
|
||||||
|
\node[box] (jvol) at (17.4,-1.9) {\texttt{jenkins-home}\\jobs, users,\\credentials};
|
||||||
|
\draw[arr] (browser) -- node[lbl, above=2pt]{HTTPS} (fw);
|
||||||
|
\draw[arr] (fw) -- (caddy);
|
||||||
|
\draw[arr] (caddy.north) |- node[lbl, pos=0.75]{HTTP} (gitea.west);
|
||||||
|
\draw[arr] (caddy.south) |- node[lbl, pos=0.75]{HTTP} (jenkins.west);
|
||||||
|
\draw[arr, dashed, devopsGreen] ([xshift=-6mm]gitea.south) -- node[lbl, left=2pt]{1. webhook} ([xshift=-6mm]jenkins.north);
|
||||||
|
\draw[arr, dashed, devopsBlue] ([xshift=6mm]jenkins.north) -- node[lbl, right=2pt, align=left]{2. checkout + status\\via Caddy alias} ([xshift=6mm]gitea.south);
|
||||||
|
\draw[arr] (gitea) -- (gvol);
|
||||||
|
\draw[arr] (jenkins) -- (jvol);
|
||||||
|
\node[draw, dashed, rounded corners, fit=(caddy) (gitea) (jenkins) (gvol) (jvol), inner sep=8pt,
|
||||||
|
label={[font=\scriptsize]above:Droplet \texttt{The-Ocean} (1\,GiB) / Docker network \texttt{gitea\_web}}] {};
|
||||||
|
\end{tikzpicture}}
|
||||||
|
\caption{Actual deployment, October 2026. Only Caddy's 80/443 are public.
|
||||||
|
Gitea sends the webhook to \texttt{http://jenkins:8080} on the private
|
||||||
|
network; Jenkins checks out code and posts statuses to
|
||||||
|
\texttt{https://git.yebilly.me}, which resolves to Caddy inside the Docker
|
||||||
|
network. Builds run on the controller; there is no separate agent.}
|
||||||
|
\label{Figure:JenkinsDeployment}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\paragraph{Integration identity.}
|
||||||
|
Gitea user \texttt{jenkins-bot} is a \emph{Write} collaborator on
|
||||||
|
\texttt{ssw590-group1/vpn-dns-gateway}, the lowest repository role that can
|
||||||
|
post commit statuses. Its token \texttt{jenkins-ci} has repository
|
||||||
|
read/write and organization/user read scopes only. The token is stored in
|
||||||
|
Jenkins as credential \texttt{gitea-jenkins-bot}; Jenkins' Gitea server entry
|
||||||
|
points to \texttt{https://git.yebilly.me} with hook management disabled.
|
||||||
|
|
||||||
|
\paragraph{Job and events.}
|
||||||
|
The Multibranch Pipeline job \texttt{vpn-dns-gateway} discovers branches that
|
||||||
|
are not also PRs, and PRs from the origin repository using \emph{the current
|
||||||
|
pull request revision}, so Jenkins builds the PR head itself rather than a
|
||||||
|
temporary merge. PRs from forks are not discovered. The repository webhook
|
||||||
|
\texttt{jenkins-ci} posts JSON to
|
||||||
|
\texttt{http://jenkins:8080/gitea-webhook/post} for \emph{Push},
|
||||||
|
\emph{Pull Request}, and \emph{Pull Request Synchronized} events on all
|
||||||
|
branches. Gitea's \texttt{webhook.ALLOWED\_HOST\_LIST} is set to
|
||||||
|
\texttt{jenkins}, so Gitea may call no other private host. The first
|
||||||
|
repository scan (October 22, 22:39:55) authenticated as the bot and reported
|
||||||
|
no \texttt{Jenkinsfile} yet, as expected (Figure~\ref{Figure:JenkinsScan}).
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{images/jenkins-first-scan-2026-10-22.png}
|
||||||
|
\caption{October 22, 2026, 22:39 UTC: first scan of the Multibranch job; the
|
||||||
|
bot credential reaches \texttt{ssw590-group1/vpn-dns-gateway}, and the
|
||||||
|
executor count is 1.}
|
||||||
|
\label{Figure:JenkinsScan}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\paragraph{Delivery evidence.}
|
||||||
|
A test delivery at 22:54:06 on October 22 returned HTTP 200 with body
|
||||||
|
\texttt{Processed} from \texttt{Server: Jetty(12.1.13)}, that is, from Jenkins
|
||||||
|
itself (Figure~\ref{Figure:JenkinsWebhook}). Real deliveries then started every
|
||||||
|
run in Table~\ref{Table:JenkinsSequence}; for example, the push of
|
||||||
|
\texttt{52b297c} produced the event ``Pull request \#15 event at 11:10:32 PM
|
||||||
|
on Oct 22, 2026'' that started \texttt{PR-15} run~2.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{images/gitea-webhook-delivery-2026-10-22.png}
|
||||||
|
\caption{October 22, 2026, 22:54 UTC: Gitea webhook \texttt{jenkins-ci} with
|
||||||
|
Push, Pull Request, and Pull Request Synchronized events; test delivery
|
||||||
|
answered 200 \texttt{Processed} by Jenkins. A Jenkins reporting-endpoint ID
|
||||||
|
in one header is blurred.}
|
||||||
|
\label{Figure:JenkinsWebhook}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\paragraph{Diagnosing a failed delivery.}
|
||||||
|
If a push does not start a build: (1) open \emph{Repository Settings
|
||||||
|
$\rightarrow$ Webhooks $\rightarrow$ jenkins-ci $\rightarrow$ Recent
|
||||||
|
Deliveries} and read the response; (2) ``can only call allowed HTTP
|
||||||
|
servers'' means \texttt{ALLOWED\_HOST\_LIST} was lost, so recreate the Gitea
|
||||||
|
container from Compose; (3) a connection error means Jenkins is down, so run
|
||||||
|
\texttt{docker compose ps} and \texttt{docker compose logs --tail 100 jenkins};
|
||||||
|
(4) a 200 response with no build means the branch has no \texttt{Jenkinsfile}
|
||||||
|
or the event type is not selected, so use \emph{Scan Multibranch Pipeline
|
||||||
|
Now} in Jenkins and read its log. \emph{Redeliver} on the delivery replays
|
||||||
|
the event after the fix.
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{Versioned Pipeline and Tests}
|
||||||
|
\label{Section:JenkinsPipeline}
|
||||||
|
\index{Jenkinsfile}
|
||||||
|
|
||||||
|
The repository root contains
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/Jenkinsfile}{\texttt{Jenkinsfile}},
|
||||||
|
the instructor's permitted Python example
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/pricing.py}{\texttt{pricing.py}},
|
||||||
|
and its unit tests in
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/tests/test_pricing.py}{\texttt{tests/test\_pricing.py}}.
|
||||||
|
The Declarative \gls{jenkinsfile} is:
|
||||||
|
\begin{minted}{groovy}
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
options { skipDefaultCheckout() }
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps { checkout scm }
|
||||||
|
}
|
||||||
|
stage('Syntax check') {
|
||||||
|
steps { sh 'python3 -m py_compile pricing.py' }
|
||||||
|
}
|
||||||
|
stage('Test') {
|
||||||
|
steps { sh 'python3 -m unittest discover -s tests -v' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\end{minted}
|
||||||
|
\begin{itemize}[nosep]
|
||||||
|
\item \textbf{Checkout} fetches the revision Jenkins selected; for PR~\#15 it
|
||||||
|
fetched \texttt{refs/pull/15/head} and checked out the PR head.
|
||||||
|
\item \textbf{Syntax check} compiles \texttt{pricing.py}; a syntax error fails here.
|
||||||
|
\item \textbf{Test} runs two unit tests: \texttt{10 * 3 == 30}, and quantity 0
|
||||||
|
raises \texttt{ValueError}. Expected passing output ends in
|
||||||
|
\texttt{Ran 2 tests \ldots OK}; any failing assertion ends in
|
||||||
|
\texttt{FAILED} and a non-zero exit, which fails the stage.
|
||||||
|
\end{itemize}
|
||||||
|
\textbf{Dependencies:} Python 3.13.5 and Git 2.47.3 come from the Debian
|
||||||
|
packages in the Jenkins image; the tests use only the standard library.
|
||||||
|
\textbf{Clean run:} on any machine with Python 3, check out a commit and run
|
||||||
|
\texttt{python3 -m py\_compile pricing.py} then
|
||||||
|
\texttt{python3 -m unittest discover -s tests -v} from the repository root.
|
||||||
|
In Jenkins, \emph{Build Now} on a branch or PR job repeats the run in a fresh
|
||||||
|
checkout of the same commit.
|
||||||
|
|
||||||
|
Figure~\ref{Figure:JenkinsStages} shows the distinct stage results of a run,
|
||||||
|
here the deliberate failure, with the tested commit identified in its log.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{images/jenkins-pr15-build2-failure-2026-10-22.png}
|
||||||
|
\caption{October 22, 2026: \texttt{PR-15} run~2 for commit \texttt{52b297c}
|
||||||
|
(started by the PR event at 23:10:32 UTC). Checkout and Syntax check passed;
|
||||||
|
Test failed with \texttt{AssertionError: 13 != 30} and exit code~1.}
|
||||||
|
\label{Figure:JenkinsStages}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{Required Merge Gate}
|
||||||
|
\label{Section:JenkinsGate}
|
||||||
|
\index{branch protection}
|
||||||
|
|
||||||
|
At 23:09:44 on October 22, Billy saved a branch-protection rule for
|
||||||
|
\texttt{main} (Figure~\ref{Figure:JenkinsProtection}). Its stored settings
|
||||||
|
are: direct push disabled; status check required with the exact context
|
||||||
|
\textbf{\texttt{vpn-dns-gateway/pipeline/pr-main}}; one approval required;
|
||||||
|
merge blocked on rejected reviews; stale approvals dismissed when new commits
|
||||||
|
are pushed; administrators may not override; no bypass list.\footnote{\url{https://docs.gitea.com/usage/access-control/protected-branches}}
|
||||||
|
|
||||||
|
\textbf{How the status reaches Gitea:} at the start and end of each run, the
|
||||||
|
Gitea plugin calls Gitea's commit-status API with the bot token for the
|
||||||
|
tested commit, for example ``\texttt{[Gitea] Notifying pull request build
|
||||||
|
status: FAILURE There was a failure building this commit}''. The context
|
||||||
|
name is built from the job and the PR target branch. Gitea compares it with
|
||||||
|
the protected branch's required context on the PR's latest head commit; a
|
||||||
|
webhook delivery or a green Jenkins page alone does not satisfy the
|
||||||
|
gate.\footnote{\url{https://plugins.jenkins.io/gitea/}}
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.85\linewidth]{images/gitea-branch-protection-2026-10-22.png}
|
||||||
|
\caption{October 22, 2026: protection rule for \texttt{main}. The required
|
||||||
|
pattern \texttt{vpn-dns-gateway/pipeline/pr-main} is marked
|
||||||
|
\emph{Matched} against checks Gitea has seen; administrators must follow
|
||||||
|
the rule.}
|
||||||
|
\label{Figure:JenkinsProtection}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.92\linewidth]{images/gitea-pr15-blocked-2026-10-22.png}
|
||||||
|
\caption{\textbf{Merge blocked.} October 22, 2026, about 23:11 UTC: PR~\#15
|
||||||
|
head \texttt{52b297c} fails required check
|
||||||
|
\texttt{vpn-dns-gateway/pipeline/pr-main} (Jenkins
|
||||||
|
\href{https://ci.yebilly.me/job/vpn-dns-gateway/job/PR-15/2/}{PR-15 run~2});
|
||||||
|
Gitea reports that required checks were not successful and no approval is
|
||||||
|
granted.}
|
||||||
|
\label{Figure:JenkinsBlocked}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.92\linewidth]{images/gitea-pr15-passing-2026-10-22.png}
|
||||||
|
\caption{\textbf{Passing after repair.} October 22, 2026, after 23:15:26 UTC:
|
||||||
|
PR~\#15 head \texttt{9381d2a} passes required check
|
||||||
|
\texttt{vpn-dns-gateway/pipeline/pr-main} (Jenkins
|
||||||
|
\href{https://ci.yebilly.me/job/vpn-dns-gateway/job/PR-15/3/}{PR-15 run~3}).
|
||||||
|
The only remaining condition is the required peer approval.}
|
||||||
|
\label{Figure:JenkinsPassing}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{Failure, Repair, and Review}
|
||||||
|
\label{Section:JenkinsReview}
|
||||||
|
|
||||||
|
Billy opened
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/issues/14}{issue~\#14},
|
||||||
|
pushed branch \texttt{feature/issue-14}, and opened
|
||||||
|
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/15}{PR~\#15}
|
||||||
|
with \texttt{Closes \#14} in its description and Vincent as reviewer. The
|
||||||
|
controlled failure changed multiplication to addition in \texttt{pricing.py}
|
||||||
|
on the same branch; the repair restored it.
|
||||||
|
|
||||||
|
\clearpage
|
||||||
|
\begin{tabularx}{\linewidth}{L{2.6cm}L{1.6cm}L{2.0cm}L{1.9cm}Y}
|
||||||
|
\caption{PR~\#15 sequence, October 22--23, 2026 (UTC)\label{Table:JenkinsSequence}}\\
|
||||||
|
\toprule \textbf{Event} & \textbf{Commit} & \textbf{Jenkins run} & \textbf{Check} & \textbf{Detail}\\ \midrule
|
||||||
|
Initial push / PR & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/commit/ad35197ee4905767b0c3d74159a8dfee29d5c37a}{\texttt{ad35197}} & PR-15 \#1 & success 23:02:18 & Jenkins service, app, tests, \texttt{Jenkinsfile}\\
|
||||||
|
Controlled failure & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/commit/52b297c2f33881f7b483808c0040758cee2a1d8f}{\texttt{52b297c}} & PR-15 \#2 & failure 23:10:51 & \texttt{AssertionError: 13 != 30}; merge blocked\\
|
||||||
|
Repair & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/commit/9381d2aa9a11cb7be1b157ea5ecb1318f9a014f0}{\texttt{9381d2a}} & PR-15 \#3 & success 23:15:26 & Multiplication restored; 2 tests OK\\
|
||||||
|
Peer review & \texttt{9381d2a} & --- & --- & \texttt{vsun1} approved at 00:02:40, Oct 23\\
|
||||||
|
Merge & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/commit/420ba4c56b1c3efa50099a85c16c750a9815091a}{\texttt{420ba4c}} & main \#1 & success 00:55:37 & Merged by \texttt{bill} at 00:55:21; issue \#14 closed automatically\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
Each Jenkins log names the commit it checked out
|
||||||
|
(\texttt{Checking out Revision 52b297c2f338\ldots} for run~2,
|
||||||
|
\texttt{9381d2aa9a11\ldots} for run~3), and each matches the PR head shown
|
||||||
|
in Gitea at that time. The branch job \texttt{feature/issue-14}~\#1 also
|
||||||
|
passed on \texttt{ad35197} before the PR existed; its context
|
||||||
|
\texttt{vpn-dns-gateway/pipeline/head} is not the required one.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.92\linewidth]{images/gitea-pr15-merged-2026-10-22.png}
|
||||||
|
\caption{October 23, 2026, 00:55 UTC: PR~\#15 merged into \texttt{main} as
|
||||||
|
\texttt{420ba4c}. The timeline shows the passing, failing, and repaired
|
||||||
|
commits and \texttt{vsun1}'s approval.}
|
||||||
|
\label{Figure:JenkinsMerged}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{Credentials and Build Boundary}
|
||||||
|
\label{Section:JenkinsBoundary}
|
||||||
|
\index{Jenkins!build boundary}
|
||||||
|
|
||||||
|
\paragraph{Secrets.}
|
||||||
|
The only integration secret is the \texttt{jenkins-bot} token, stored as
|
||||||
|
the Jenkins credential \texttt{gitea-jenkins-bot} (System, Global scope) and
|
||||||
|
encrypted in \texttt{jenkins-home}. It never appears in Git, Compose, the
|
||||||
|
console log (the log prints only the credential's description), or this
|
||||||
|
manual. The initial administrator password was read once by Billy in his own
|
||||||
|
terminal and is no longer used. Hints for all accounts are in
|
||||||
|
Table~\ref{Table:Passwords}.
|
||||||
|
|
||||||
|
\paragraph{Where builds run, and the risk.}
|
||||||
|
Builds run on the Jenkins \gls{controller} executor (one executor); there is
|
||||||
|
no separate \gls{build-agent}, controller executors are not zero, and no agent
|
||||||
|
port is open. Pipeline code runs as the container's \texttt{jenkins} user
|
||||||
|
with read access to \texttt{jenkins-home}, which holds the encrypted
|
||||||
|
credentials and their key, so a malicious \texttt{Jenkinsfile} could steal
|
||||||
|
the bot token.\footnote{\url{https://www.jenkins.io/doc/book/security/controller-isolation/}}
|
||||||
|
Compensating restrictions:
|
||||||
|
\begin{itemize}[nosep]
|
||||||
|
\item Only Billy and Vincent can push to the repository, so only they can
|
||||||
|
change the \texttt{Jenkinsfile}; \texttt{main} accepts changes only through
|
||||||
|
reviewed PRs.
|
||||||
|
\item PRs from forks are not discovered, so untrusted code never runs.
|
||||||
|
\item No Docker socket is mounted and the container is not privileged; its
|
||||||
|
memory, CPU, and process count are capped.
|
||||||
|
\item The token is limited to one repository role (Write) and read-only
|
||||||
|
organization/user scopes, and can be revoked in Gitea without touching
|
||||||
|
Jenkins.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\paragraph{Plugin-update check.}
|
||||||
|
On October 23 at 01:03, the 63 locked plugins were compared with the Jenkins
|
||||||
|
update center for core 2.580.1. One newer version exists
|
||||||
|
(\texttt{workflow-api} \texttt{1413.v2ff1a\_5e720fa\_} $\rightarrow$
|
||||||
|
\texttt{1429.v7a\_1b\_efb\_a\_f7c5}); no security warning matches any installed
|
||||||
|
version. The update was deferred: it is not a security fix and would change
|
||||||
|
the tested set. Updates are applied by regenerating the lockfile, rebuilding
|
||||||
|
the image, and recreating the container.
|
||||||
|
|
||||||
|
\paragraph{Troubleshooting a failed build.}
|
||||||
|
Open the run's \emph{Pipeline Overview} to see which stage failed and its
|
||||||
|
log. A red \emph{Test} stage with an assertion is a code failure: fix the
|
||||||
|
code and push to the same PR. A red \emph{Checkout} usually means the token
|
||||||
|
was revoked or Gitea is unreachable: check the credential and
|
||||||
|
\texttt{curl https://git.yebilly.me} from inside the container. A run that
|
||||||
|
never starts: follow the webhook steps in
|
||||||
|
Section~\ref{Section:JenkinsTrigger}. Memory trouble (slow pages,
|
||||||
|
\texttt{OutOfMemoryError} in \texttt{docker compose logs jenkins}): check
|
||||||
|
\texttt{free -m} and \texttt{docker stats} and restart Jenkins with
|
||||||
|
\texttt{docker compose restart jenkins}.
|
||||||
|
|
||||||
|
%---------------------------------------------------------------
|
||||||
|
\section{Manual Quality and Controls}
|
||||||
|
\label{Section:JenkinsQuality}
|
||||||
|
|
||||||
|
\paragraph{Corrective actions.}
|
||||||
|
Four problems were found and fixed during this work, each recorded with its
|
||||||
|
evidence: (1) the official plugin installer ran out of its 128\,MiB heap while
|
||||||
|
reading the update-center catalog, so the Dockerfile downloads the pinned
|
||||||
|
plugins with \texttt{curl} and checks their SHA-256; (2) the first droplet
|
||||||
|
capacity run failed on upload permissions, fixed by \texttt{chmod}; (3) the
|
||||||
|
128\,MiB heap hung the web interface, fixed by the larger limits in
|
||||||
|
Section~\ref{Section:JenkinsDeployment}; (4) matrix authorization was missing
|
||||||
|
because the capacity bundle covered only Pipeline and Gitea, so
|
||||||
|
\texttt{matrix-auth} was added and the image rebuilt. Three theme plugins
|
||||||
|
(\texttt{dark-theme}, \texttt{dracula-theme}, \texttt{theme-manager}) were
|
||||||
|
installed from the web interface during setup and are not in the lockfile;
|
||||||
|
they survive in \texttt{jenkins-home} but would be lost if the volume were
|
||||||
|
recreated.
|
||||||
|
|
||||||
|
\paragraph{Operator restart and recovery note.}
|
||||||
|
Run these on the droplet as \texttt{root}:
|
||||||
|
\begin{minted}{sh}
|
||||||
|
cd ~/gitea
|
||||||
|
docker compose ps # all three services Up
|
||||||
|
docker compose restart jenkins # state stays in the volume
|
||||||
|
docker compose logs --tail 100 jenkins # startup errors, OutOfMemoryError
|
||||||
|
# after changing deploy/jenkins/plugins.txt:
|
||||||
|
docker compose build jenkins && docker compose up -d jenkins
|
||||||
|
\end{minted}
|
||||||
|
After a droplet reboot, Docker starts all three services because of their
|
||||||
|
restart policies; Jenkins needs about one minute before the login page
|
||||||
|
answers. Gitea does not depend on Jenkins, so a Jenkins outage only delays
|
||||||
|
checks (PRs stay blocked until Jenkins reports).
|
||||||
|
|
||||||
|
\paragraph{Cost, ownership, and cleanup.}
|
||||||
|
Jenkins adds no paid resource; it uses the droplet's 1\,GiB Basic plan
|
||||||
|
(listed at \$6/month on DigitalOcean's pricing page on October 21, 2026; the
|
||||||
|
account's billing was not re-checked here) and about 0.9\,GB of disk for its
|
||||||
|
image. Billy administers the droplet and Jenkins; Vincent reviews. To remove
|
||||||
|
Jenkins: delete the \texttt{main} protection's required check, stop and
|
||||||
|
remove the service (\texttt{docker compose rm -sf jenkins}), delete the volume
|
||||||
|
(\texttt{docker volume rm gitea\_jenkins-home}), remove the \texttt{ci} block
|
||||||
|
from the Caddyfile and the \texttt{ci} DNS record, delete the webhook, and
|
||||||
|
delete the \texttt{jenkins-bot} user and token.
|
||||||
|
|
||||||
|
\paragraph{Document controls.}
|
||||||
|
This version is 4.0. Document History records the change and both updated
|
||||||
|
tables in \ChapterRef{HostsPasswords}: the Hosts table adds \texttt{ci.yebilly.me},
|
||||||
|
the Jenkins service, and the 1\,GiB resize; the Passwords table adds the
|
||||||
|
Jenkins administrators, the \texttt{jenkins-bot} account, and its token.
|
||||||
|
New glossary terms are indexed, and AI assistance is recorded in
|
||||||
|
\ChapterRef{AIPromptLog}.
|
||||||
|
|
||||||
|
\endgroup
|
||||||
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 161 KiB |
|
After Width: | Height: | Size: 302 KiB |
|
After Width: | Height: | Size: 163 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 274 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 252 KiB |
|
After Width: | Height: | Size: 226 KiB |