From 253e911e44e996cd45cd262d084a2290ff18ac8e Mon Sep 17 00:00:00 2001 From: "hcm@590hcm.dev" Date: Fri, 23 Oct 2026 21:30:44 +0000 Subject: [PATCH] Keep a single verified Jenkins chapter after editor replacement --- devopsJenkinsCI.tex | 326 -------------------------------------------- 1 file changed, 326 deletions(-) diff --git a/devopsJenkinsCI.tex b/devopsJenkinsCI.tex index 2dfa11e..9ea13dc 100644 --- a/devopsJenkinsCI.tex +++ b/devopsJenkinsCI.tex @@ -325,329 +325,3 @@ Remaining finalization items are peer approval, merge/issue-closure evidence, verification of the instructor's own approved private access path, and a decision on the inherited unrestricted SSH exposure and administrator merge override. These are reported as open, rather than implied complete by green CI. -\chapter{Continuous Integration with Jenkins} -\ChapterLabel{JenkinsCI} -\index{Jenkins}\index{continuous integration}\index{merge gate} - -This chapter records the Jenkins CI implementation and the controlled failure -and repair observed on October 23, 2026. The team continues on AWS Lightsail; -MB reported instructor approval for that substitution for DigitalOcean. -The application is the assignment's Python pricing example in -\href{https://git.590hcm.dev/SSW590Team/pricing-app}{\texttt{SSW590Team/pricing-app}}. -\textbf{Review status: the technical checks below are complete, but peer -approval and the eventual merge of PR~2 remain pending. This is a review draft.} - -\section{Jenkins Deployment and Persistence} -Jenkins runs as a controlled Docker service alongside the existing Gitea, -Caddy, and Actions runner. Its official image is -\texttt{jenkins/jenkins:2.580.1-lts-jdk21}, pinned to digest -{\footnotesize\path{sha256:a660310e39ade10631f774bacd5219de767dfd08947ea5c32a739b5e5bb382c1}}. -The reviewed -\href{https://git.590hcm.dev/SSW590Team/pricing-app/src/branch/main/deploy}{deployment directory} -contains the non-secret Compose configuration, agent Dockerfile, initialization -procedure, proxy configuration, and plugin record. The live stack is under -\path{/home/ubuntu/jenkins-deploy}. The complete plugin inventory is retained -with this review package; installed integration components include Gitea -\texttt{286.v0740a\_413c1eb\_} and Workflow Multibranch -\texttt{842.v3a\_b\_59b\_57b\_e6e}. - -The Lightsail host has 2 vCPUs, 2 GB RAM, and a 60 GB disk. On October 23, -external verification and host inspection found about 44 GB disk free. -Observed container memory was about 498 MiB for Jenkins and 125 MiB for its -Python agent. The controller has a 768 MiB limit, one CPU limit, and Java heap -\texttt{-Xms128m -Xmx384m}; the agent has a 384 MiB limit and 0.75 CPU limit. -The existing 1 GB TeX jobs should not overlap with CI unnecessarily on this -small host. These observations are capacity checks, not a sustained load test. - -\begin{verbatim} -restart: unless-stopped -ports: - - "127.0.0.1:8080:8080" -volumes: - - jenkins_home:/var/jenkins_home -\end{verbatim} - -The actual named volume is \texttt{jenkins-deploy\_jenkins\_home}. -The named administrator account is \texttt{max}; the user personally created -its password. Registration is disabled. Jenkins currently grants full control -to authenticated users; only the named administrator has been provisioned. -Do not add other accounts without reviewing that authorization strategy. - -A controller restart test on October 23 retained the configuration, named -administrator, Python node, multibranch job, and successful build history. -The verification package includes before/after records, with a new test -repeated after the PR failure and repair. Expected result: service restarts -without loss of these objects. Actual result is recorded in the matching -runtime JSON files. \textbf{Restart persistence is not a backup or restore test.} - -\section{HTTPS, Access, and Firewall} -The complete Jenkins login URL is -\url{https://ci.590hcm.dev:8443/login}. It requires the approved SSH tunnel. -Name.com DNS has an A record for \texttt{ci.590hcm.dev} pointing to -\texttt{184.193.0.32}, TTL 300. On the accessing computer, map the CI name to -loopback in the hosts file, then run the following with that operator's own -approved Lightsail SSH key. The instructor needs approved SSH access to this -path, but no Jenkins account merely to view the login page. Access for a new -person must be arranged by the host owner; the owner's private key must not -be shared. - -\begin{verbatim} -# Local hosts entry: -127.0.0.1 ci.590hcm.dev -# Use the operator's approved key file: -ssh -i /path/to/approved-key.pem -N \ - -L 127.0.0.1:8443:127.0.0.1:443 ubuntu@184.193.0.32 -\end{verbatim} - -Caddy terminates TLS and forwards to \texttt{jenkins:8080}. It accepts the -CI application route only when the connection arrives from the Docker bridge -gateway \texttt{172.18.0.1}, as it does for host-loopback SSH forwarding. -Other CI requests receive HTTP 403. This boundary trusts the host and its -container network. The Jenkins URL is set to -\url{https://ci.590hcm.dev:8443/}; Caddy supplies its standard forwarded -request headers. The certificate was validated with the normal system trust -store: issuer Let's Encrypt YE2, valid from October 23, 2026 at 15:18:29 UTC -through January 21, 2027 at 15:18:28 UTC. - -The live public HTTP endpoint returned 308 with -\url{https://ci.590hcm.dev/login} as its Location; a direct public HTTPS -request returned 403. The tunnel URL returned 200 and rendered the login -page. Caddy automatic HTTPS handles renewal with its existing persistent data -volume; this was inspected as configuration, not demonstrated by waiting for -a certificate renewal cycle \cite{caddy-ci-autohttps}. \begin{figure}[htbp]\centering -\includegraphics[width=0.85\linewidth]{prism-uploads/ch4-https-login.jpg} -\caption{October 23, 2026: Jenkins login form opened through the approved -SSH tunnel at the complete HTTPS hostname. This proves web availability, -not application test success.}\label{Figure:CILogin} -\end{figure} -The temporary -\texttt{127.0.0.1:18080} tunnel used for initial setup is not the published -operational URL. - -\begin{table}[htbp]\centering\small -\begin{tabular}{lcc} -\toprule External TCP test, October 23, 2026 & IPv4 & IPv6\\\midrule -SSH 22 & reachable & reachable\\ -HTTP 80 & reachable & reachable\\ -HTTPS 443 & reachable & timed out\\ -Gitea backend 3000 & timed out & timed out\\ -Jenkins backend 8080 & timed out & timed out\\ -Inbound agent 50000 & timed out & timed out\\\bottomrule -\end{tabular} -\caption{Tests from the user's Mac, outside Lightsail, at 21:14:56 UTC. -Timeouts show lack of reachability from this vantage, not a universal firewall proof.} -\label{Table:CIExposure} -\end{table} - -The host is dual-stack. Cloud rules previously observed allow 80 and 22 from -any IPv4/IPv6 address and 443 from any IPv4 address. UFW is inactive. Docker -publishes Caddy 80/443 and binds Jenkins 8080 only to host loopback; the -Python agent publishes no port. Jenkins' inbound agent listener is disabled. -\textbf{Unrestricted SSH remains a corrective action inherited from Chapter 2.} -Verify another approved administrator can still connect before narrowing it. -No claim is made that HTTPS or the CI proxy replaces cloud and host controls. - -\section{Gitea Trigger and Traceability} -The repository-scoped Gitea webhook posts JSON to -{\footnotesize\path{http://jenkins:8080/gitea-webhook/post}} on the shared container bridge. -Its selected events are create, delete, push, pull request, and pull-request -synchronization; the branch filter is \texttt{*}. Gitea's webhook destination -allowlist is narrowed to \texttt{jenkins}. The network is named -\texttt{gitea-deploy\_internal}, but its Docker \texttt{Internal} setting is -false; it is not an egress-isolated network. - -The dedicated restricted non-admin Gitea identity is \texttt{jenkins-ci}. -It has write collaboration on pricing-app only. Its token scopes are -\texttt{read:user} and \texttt{write:repository}; the latter is needed because -this Gitea version groups commit-status writing with repository write. -Automatic webhook administration is disabled for this identity. The human -repository administrator configures the hook. - -Jenkins uses the Gitea plugin with a Multibranch Pipeline. The API endpoint is -\path{http://gitea:3000}; checkout uses the same private route. PR discovery -uses strategy \texttt{HEAD}, not a synthetic merge revision. Fork PR -discovery is not enabled. For the repair, webhook delivery -\path{86a0253b-7fd1-430b-a019-1c5fb4329727} recorded -\texttt{pull\_request\_sync}, HTTP 200, body \texttt{Processed}, at -21:14:24 UTC. It triggered -\href{https://ci.590hcm.dev:8443/job/pricing-app/job/PR-2/2/}{PR-2 build 2} -for commit \texttt{747ed9a82f}. A delivered webhook only proves transport; -the matching run and status below prove verification. - -\begin{figure}[htbp]\centering -\begin{tikzpicture}[node distance=9mm,box/.style={draw,rounded corners,align=center,font=\scriptsize,inner sep=5pt},>=stealth] -\node[box] (browser) {\textless\textless device\textgreater\textgreater\\Team browser + SSH tunnel}; -\node[box,below=of browser] (proxy) {\textless\textless container\textgreater\textgreater\\Caddy TLS proxy}; -\node[box,below left=13mm and 5mm of proxy] (gitea) {\textless\textless container\textgreater\textgreater\\Gitea 1.22.3}; -\node[box,below right=13mm and 5mm of proxy] (controller) {\textless\textless container\textgreater\textgreater\\Jenkins controller\\0 executors}; -\node[box,below=19mm of controller] (agent) {\textless\textless container\textgreater\textgreater\\Python SSH agent\\checkout + tests; 1 executor}; -\node[box,below=19mm of gitea] (data) {\textless\textless volume\textgreater\textgreater\\Gitea repositories + SQLite}; -\node[box,right=10mm of controller] (home) {\textless\textless volume\textgreater\textgreater\\Jenkins home}; -\draw[->] (browser)--node[right,font=\tiny]{SSH to host; local 8443 to host 443}(proxy); -\draw[->] (proxy)--node[above right,font=\tiny]{private 8080}(controller); -\draw[->] (proxy)--node[above left,font=\tiny]{private 3000}(gitea); -\draw[->] (gitea)--node[above,font=\tiny]{webhook 8080}(controller); -\draw[->] (controller) to[bend left=18] node[below,font=\tiny]{API status 3000}(gitea); -\draw[->] (controller)--node[right,font=\tiny]{private SSH 22}(agent); -\draw[->] (agent) to[bend left=12] node[below,font=\tiny]{checkout 3000}(gitea); -\draw[->] (gitea)--(data);\draw[->] (controller)--(home); -\end{tikzpicture} -\caption{Actual deployment on the AWS Lightsail device Gitea-Project. -Caddy is reached through the approved access path; webhook, agent, and data -connections stay on the container bridge. Public CI requests are denied.} -\label{Figure:CIDeployment} -\end{figure} - -\section{Versioned Pipeline and Tests} -The root -\href{https://git.590hcm.dev/SSW590Team/pricing-app/src/branch/main/Jenkinsfile}{Jenkinsfile} -uses the \texttt{python} agent label. Checkout fetches the selected revision; -the run prints its exact commit and Python version. The next stage compiles -\texttt{pricing.py}; the final stage runs unittest discovery. These checks -use Python 3.13.5 and its standard library, with no pip dependency. The -agent image derives from official Jenkins SSH Agent digest -{\footnotesize\path{sha256:5af828cead1f8f69162f6e1d827b8a6712007c13438ca9db01ae34e11ed07fd3}} -and installs Debian's \texttt{python3=3.13.5-1}. Transitive Debian packages -are not fully locked; record an image digest on rebuild. - -To reproduce from a clean checkout of the linked commit on an executor with -Python installed: -\begin{verbatim} -python3 --version -python3 -m py_compile pricing.py -python3 -m unittest discover -s tests -v -\end{verbatim} -Expected passing output is two tests and \texttt{OK}. The intentional -regression passed syntax checking but failed \texttt{test\_total}: -\texttt{AssertionError: 13 != 30}; Jenkins returned FAILURE. The repaired -commit passed both stages and returned SUCCESS. The run uses -\path{/home/jenkins/agent} in the agent container; the controller does not -execute application tests \cite{jenkins-ci-isolation}. - -\begin{figure}[htbp]\centering -\includegraphics[width=\linewidth]{prism-uploads/ch4-jenkins-repair-run.jpg} -\caption{October 23, 2026: PR-2 build 2 shows SUCCESS, the private webhook -origin, and repair commit 747ed9a82feee9018ac8fe0d9eab8c007d23caf8. -The Jenkins UI displays its own timezone; the narrative uses UTC explicitly.} -\label{Figure:CIRepairRun} -\end{figure} - -\section{Required Merge Gate} -The \texttt{main} protection rule disables direct pushes, requires one -approval, dismisses stale approvals, blocks rejected reviews, and requires -the exact context \path{pricing-app/pipeline/pr-main}. The branch build's -\path{pricing-app/pipeline/head} context is distinct and cannot satisfy -that PR-specific rule. The Gitea plugin publishes pending and final results -using the integration identity; after repair, the successful required status -belongs to the new PR head commit, not the earlier failed commit. - -\textbf{Administrator exception:} this Gitea 1.22 installation displays an -administrator override. The screenshots were captured from the owner's -account, so they show that exception. No override was used. The required -check is configured for the normal merge process, but an absolute guarantee -that administrators cannot bypass it has not been demonstrated. Peer review -and normal merge remain necessary before final submission. - -\begin{figure}[htbp]\centering -\includegraphics[width=\linewidth]{prism-uploads/ch4-failed-check.jpg} -\caption{October 23, 2026: failed commit 5c837eaae7a49a1a24b9aa1d9ac2b886b5b9be14; -required context pricing-app/pipeline/pr-main is red. The normal conditions -are unmet; the owner interface separately exposes its administrator override. -See \href{https://git.590hcm.dev/SSW590Team/pricing-app/pulls/2}{PR 2} and -\href{https://ci.590hcm.dev:8443/job/pricing-app/job/PR-2/1/}{failed run 1}.} -\label{Figure:CIFailedGate} -\end{figure} - -\begin{figure}[htbp]\centering -\includegraphics[width=\linewidth]{prism-uploads/ch4-passing-check.jpg} -\caption{October 23, 2026: repair commit 747ed9a82feee9018ac8fe0d9eab8c007d23caf8; -required context pricing-app/pipeline/pr-main is green. Peer approval is -still pending. See the same PR and -\href{https://ci.590hcm.dev:8443/job/pricing-app/job/PR-2/2/}{passing run 2}.} -\label{Figure:CIPassingGate} -\end{figure} - -\section{Failure, Repair, and Review} -\href{https://git.590hcm.dev/SSW590Team/pricing-app/issues/1}{Issue 1} -defines the exercise. \href{https://git.590hcm.dev/SSW590Team/pricing-app/pulls/2}{PR 2} -contains \texttt{Closes \#1} and uses branch -\path{feature/issue-1-ci-validation} with base \texttt{main}. -The controlled change replaced multiplication with addition, then a second -commit restored multiplication on that same branch. Thus the final net code -diff is empty while the two commits and both build outcomes remain auditable. - -\begin{longtable}{L{2.3cm}L{3.1cm}L{6.5cm}} -\toprule October 23 (UTC) & Commit / run & Expected and actual result\\\midrule -21:10--21:11 & \texttt{5c837eaae7}; PR-2/1 & Syntax passes; test\_total fails, 13 instead of 30. Jenkins FAILURE and required PR status failure observed.\\ -21:14 & \texttt{747ed9a82f}; PR-2/2 & Correction restores multiplication. New webhook, checkout of new head, two tests pass, Jenkins SUCCESS and required PR status success observed.\\ -Pending & Peer review & Hailey or Carmen must review from their own account; no approval has been invented or submitted for them.\\ -Pending & Merge / closure & Merge through the normal reviewed flow, confirm merge SHA and automatic issue closure, then finalize this chapter.\\\bottomrule -\end{longtable} - -Both PR runs are retained and their sanitized console logs are in the review -package. Application code was changed in a feature branch; neither Gitea nor -Jenkins was intentionally broken. A controller restart was an operational -persistence test, not the failure exercise. - -\section{Credentials and Build Boundary} -The Gitea token is in Jenkins credentials under -\texttt{gitea-jenkins-ci-token}; the agent SSH key is a SYSTEM credential -\texttt{python-agent-ssh}. Values are excluded from this manual and source -control. The host's protected secrets directory retains bootstrap/operator -material outside the repository; temporary controller bootstrap files were -removed after import. Restrict that directory to administrators and review -retention when rotating credentials. - -The controller has zero executors and its inbound agent TCP listener is -disabled. The agent has one exclusive \texttt{python} executor and a pinned -SSH host key. Neither CI container mounts the Docker socket or the host's -administrative SSH key. The Jenkinsfile can execute arbitrary commands: -pricing-app writers, including the explicitly approved integration identity, -must be trusted. Do not give untrusted contributions credentials; fork PR -discovery is disabled. Separate containers reduce exposure but do not make -malicious trusted pipeline code safe. - -The operator's plugin check compares the recorded installed versions with -Jenkins' official update-center metadata, refreshed through Check now on October 23. The evidence records the -check time and any version differences; this is a check, not an automatic -upgrade. Review advisories, compatibility, and available capacity before -updating. The check found Pipeline API 1413.v2ff1a\_5e720fa\_ installed and 1429.v7a\_1b\_efb\_a\_f7c5 available; installation was deferred for compatibility review. Retain the known-good image and plugin record for rollback. - -\begin{enumerate} -\item Failed webhook: inspect its delivery status/body and event type in Gitea; -check the allowed destination \texttt{jenkins}, Docker DNS/network, container -state, and Jenkins webhook logs. Correlate the delivery with its SHA and run. -Do not publish 8080 as a shortcut. -\item Checkout failure: verify the integration account still has pricing-app -access, token scope and Jenkins credential ID, and agent reachability to -\texttt{gitea:3000}. Do not print tokens while testing. -\item Test failure: identify the failing stage and assertion, fix code on the -same feature branch, and push. Confirm the new run/status matches the new SHA. -\item Offline agent or memory pressure: check the private SSH host key, -credential, node log, container limits, disk space, and concurrent TeX builds. -Do not disable host-key verification or grant Docker privileges. -\item Restart: from \path{/home/ubuntu/jenkins-deploy}, run -\texttt{docker compose restart} for the \texttt{jenkins} and \texttt{python-agent} services; verify login, agent -online state, job history, and a new check. Never remove named volumes as -routine troubleshooting. -\end{enumerate} - -\section{Manual Quality and Controls} -This revision adds a dated implementation narrative, actual deployment -diagram, links to the configuration and matching runs, failed/passing check -screenshots, and the known limits above. It updates the Hosts and Passwords -tables, history, glossary/index, citations, and AI-use log. Version 1.10 is a -review draft until a real teammate approval and normal merge are recorded. -The original chapters remain part of the existing manual. - -The service owner is the existing Lightsail administrator. No new cloud -instance or paid plan was purchased; actual billing remains in the owner's -account and was not audited here. Cleanup after the course requires an owner -decision: preserve/export required evidence and configuration before removing -the CI service. Do not delete Gitea data or Jenkins volumes as part of this -review. Password hints identify storage and purpose only. - -Remaining finalization items are peer approval, merge/issue-closure evidence, -verification of the instructor's own approved private access path, and a -decision on the inherited unrestricted SSH exposure and administrator merge -override. These are reported as open, rather than implied complete by green CI.