Files
vsun1 d54d801020
vpn-dns-gateway/pipeline/head This commit looks good
vpn-dns-gateway/pipeline/pr-main This commit looks good
Finalize Assignment 6 documentation corrections
2026-10-23 18:06:07 -04:00

710 lines
38 KiB
TeX

\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/ac18f1118601157da356d09d4aa28c4084dc86eb/deploy/jenkins/plugins.txt}{\texttt{deploy/jenkins/plugins.txt}},
which pins each listed 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. At 03:35 the limits were raised to those shown above
(RAM and heap doubled to 512\,MiB and 256\,MiB, RAM plus swap 512 to
768\,MiB, CPU 0.5 to 0.75); Jenkins then answered in 45\,s instead of
184\,s on its next start, 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
(Wi-Fi \texttt{Stevens-Net}), whose public addresses fall in 155.246.0.0/16.
On October 23 Vincent tested this path from campus: on \texttt{Stevens-Net}
his public address was \texttt{155.246.151.38} and the Jenkins sign-in page
loaded (Figure~\ref{Figure:JenkinsCampus}).
Off campus, look up your public IPv4 address at \url{https://ifconfig.me}
and send it to Billy or Vincent; it is added to \texttt{CI\_TEAM\_IPS}, Caddy
is recreated, and the URL then opens. 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.
The Stevens VPN is \emph{not} an access path. On October 23 at 18:56 UTC,
Billy connected the GlobalProtect client to \texttt{sitvpn.stevens.edu}, the
only gateway it offers (Figure~\ref{Figure:StevensVPN}). The laptop's public
address stayed the team's allowlisted residential address, and its routing
table sent only 155.246.0.0/16 through the VPN adapter, while the default
route kept using the home connection. The VPN is therefore split-tunnel:
traffic to \texttt{ci.yebilly.me} leaves through the user's own internet
provider, so an off-campus visitor on the VPN would receive 403.
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{images/jenkins-campus-test-2026-10-23.png}
\caption{October 23, 2026: Vincent's campus test on \texttt{Stevens-Net}.
ifconfig.me reports public address \texttt{155.246.151.38} (the second
forwarded address is ifconfig.me's own Google front end), and
\texttt{ci.yebilly.me/login} shows the Jenkins sign-in page. The screenshots
show no clock; Billy received them at 3:43 p.m.\ Eastern. The password field
and browser profile icon are blurred.}
\label{Figure:JenkinsCampus}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{images/stevens-vpn-split-tunnel-2026-10-23.png}
\caption{October 23, 2026: GlobalProtect connected to the single gateway
\texttt{sitvpn.stevens.edu} (IPSec, about 66\,KB received in 32 minutes,
consistent with a split tunnel). Assigned and gateway IPs redacted by Billy.}
\label{Figure:StevensVPN}
\end{figure}
\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 (\emph{Manage Jenkins $\rightarrow$ System $\rightarrow$ Jenkins
Location}) is \texttt{https://ci.yebilly.me/}, as stored in the controller's
configuration (read on the droplet, October 23):
\begin{minted}{text}
$ docker exec gitea-jenkins-1 grep jenkinsUrl \
/var/jenkins_home/jenkins.model.JenkinsLocationConfiguration.xml
<jenkinsUrl>https://ci.yebilly.me/</jenkinsUrl>
\end{minted}
\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\\
HTTPS \texttt{ci\ldots/login} from campus & \texttt{Stevens-Net}, \texttt{155.246.151.38} (Vincent); Oct 23 & 200 & Sign-in page shown \StatusPass\\
Public IPv4 while on Stevens VPN & GlobalProtect connected; Oct 23 18:56:13 & Stevens address & Unchanged residential address; VPN is split-tunnel, so not offered as an access path \textbf{\footnotesize INFO}\\
\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) {\guillemotleft device\guillemotright\\Team / instructor\\browser};
\node[box, fill=devopsLightBlue] (fw) at (4.3,0) {\guillemotleft device\guillemotright\\Cloud Firewall\\\texttt{gitea-fw}, 443 / 80};
\node[box] (caddy) at (8.6,0) {\guillemotleft container\guillemotright\\Caddy TLS proxy\\allowlist for \texttt{ci}\\alias \texttt{git.yebilly.me}};
\node[box] (gitea) at (13.6,2.2) {\guillemotleft container\guillemotright\\Gitea \texttt{:3000}};
\node[box] (jenkins) at (13.6,-3.0) {\guillemotleft container\guillemotright\\Jenkins controller \texttt{:8080}\\\textbf{builds run here}\\(1 executor)};
\node[box] (gvol) at (18.4,2.2) {\guillemotleft artifact\guillemotright\\\texttt{gitea-data}\\SQLite + repos};
\node[box] (jvol) at (18.4,-3.0) {\guillemotleft artifact\guillemotright\\\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] (gitea.south) -- node[lbl, right=2pt]{1. webhook (private)} (jenkins.north);
\draw[arr, dashed, devopsBlue] (jenkins.north west) -- node[lbl, pos=0.5, left=3pt]{2. checkout + status} (caddy.south east);
\draw[arr] (gitea) -- (gvol);
\draw[arr] (jenkins) -- (jvol);
\node[draw, dashed, rounded corners, fit=(caddy) (gitea) (jenkins) (gvol) (jvol), inner sep=10pt,
label={[font=\scriptsize]above:\guillemotleft device\guillemotright\ Droplet \texttt{The-Ocean} (1\,GiB) / \guillemotleft executionEnvironment\guillemotright\ Docker network \texttt{gitea\_web}}] {};
\end{tikzpicture}}
\caption{UML deployment diagram of the actual deployment, October 2026. Only
Caddy's 80/443 are public. (1) Gitea sends the webhook to
\texttt{http://jenkins:8080} on the private network. (2) Jenkins checks out
code and posts statuses to \texttt{https://git.yebilly.me}, which resolves to
Caddy inside the Docker network; Caddy forwards to Gitea. 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}
All 14 deliveries to date, read from Gitea's delivery records on October 23,
are summarized in Table~\ref{Table:JenkinsDeliveries}.
{\small
\begin{tabularx}{\linewidth}{L{0.6cm}L{2.7cm}L{2.6cm}L{1.4cm}Y}
\caption{Gitea webhook deliveries to Jenkins (UTC)\label{Table:JenkinsDeliveries}}\\
\toprule \textbf{\#} & \textbf{Time} & \textbf{Event} & \textbf{Commit} & \textbf{Result}\\ \midrule
1 & Oct 22 22:54:06 & test push & --- & 200 \texttt{Processed}\\
2 & Oct 22 22:57:43 & push & \texttt{ad35197} & 200; started branch job\\
3 & Oct 22 23:01:59 & PR \#15 opened & \texttt{ad35197} & \textbf{failed}: client timeout awaiting headers (see below)\\
4--5 & Oct 22 23:10:32 & push, PR synchronized & \texttt{52b297c} & 200; started PR-15 run 2\\
6--7 & Oct 22 23:15:09 & push, PR synchronized & \texttt{9381d2a} & 200; started PR-15 run 3\\
8--9 & Oct 23 00:55:22 & PR closed, push & \texttt{9381d2a}, \texttt{420ba4c} & 200; started main run 1\\
10--14 & Oct 23 01:21--01:24 & push, PR \#16 events & \texttt{1149e9f}, \texttt{e4f3ce5} & 200; started PR-16 run 1 and main run 2\\
\bottomrule
\end{tabularx}}
\paragraph{Diagnosing a failed delivery.}
Delivery~3 is a real failure. Gitea recorded \texttt{Post
"http://jenkins:8080/gitea-webhook/post": context deadline exceeded
(Client.Timeout exceeded while awaiting headers)}. Diagnosis: Jenkins did
receive the event, because Gitea shows PR-15's status ``Build queued'' at
23:02:01, two seconds later, and run~1 passed at 23:02:18. Gitea did not
receive a response before its delivery timeout. PR discovery under the
0.75-CPU limit is a suspected cause of the delay, not a measured diagnosis.
No action was needed because the build completed. If a build does not
start, inspect the delivery and Jenkins logs, then use \emph{Redeliver}
or \emph{Scan Multibranch Pipeline Now} after correcting the cause.
Raising Gitea's \texttt{webhook.DELIVER\_TIMEOUT} may help if slow responses
are confirmed, but does not guarantee successful delivery.
General procedure 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 a machine with Python 3, clone the repository into a
new directory and check out the recorded commit ID of the run to reproduce.
From that repository root, 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 builds the revision selected
for that run. Verify the checked-out commit ID in its log; it may differ from
an earlier run after a new push. The pipeline's \texttt{checkout scm} step
does not explicitly clean the workspace.
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 ad35197ee490\ldots} for run~1,
\texttt{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, plus the \texttt{jenkins-bot} identity whose
token exists only inside Jenkins, have write access to the repository, so
only they can change the \texttt{Jenkinsfile}; \texttt{main} accepts changes
only through reviewed PRs, which also applies to the bot.
\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. (Counts: the capacity bundle had 59;
\texttt{matrix-auth} and \texttt{pipeline-graph-view} with its two
dependencies make 63 locked; Jenkins reports 66 installed, the other three
being the theme plugins described in Section~\ref{Section:JenkinsQuality},
which this check did not cover.) One newer version exists
(\texttt{workflow-api} \texttt{1413.v2ff1a\_5e720fa\_} $\rightarrow$
\texttt{1429.v7a\_1b\_efb\_a\_f7c5}); no security warning matched the 63
checked plugin versions. 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.}
Five 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; (5) no stage-by-stage
run view was installed, so \texttt{pipeline-graph-view} was added the same
way. 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. Measured container starts took 25\,s (warm
\texttt{docker compose restart}) to 45\,s (first start after the limit
change); a full droplet reboot was not tested, so allow about a 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. On October 23 the root filesystem had 18\,GB free of 24\,GB
(\texttt{df -h /}, 25\% used). 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 chapter was introduced in version 4.0 and corrected in 4.1 (access path,
delivery evidence, wording). Document History records both and the 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