Files
devops-it-manual/devopsJenkins.tex
T

170 lines
12 KiB
TeX

\chapter{Continuous Integration with Jenkins}
\ChapterLabel{Jenkins}
\index{Jenkins}
\index{continuous integration}
\index{merge gate}
\index{webhook}
\section{Jenkins Deployment and Persistence}
This chapter records the Chapter 3 continuous-integration work performed on October 7, 2026. The goal was to add Jenkins to the same startup environment used for the Gitea foundation, connect it to the startup product repository, and use it as the required status check for pull requests. Jenkins was deployed from the official Jenkins LTS container image and placed on the same private Docker network as Gitea and Caddy \cite{JenkinsDocker,JenkinsSecurity,JenkinsReverseProxy,GiteaWebhooks,GiteaProtectedBranches}.
\begin{devopsNote}[Evidence Boundary]
The infrastructure deployment, HTTPS proxy, raw-port blocking, Jenkins startup, plugin installation attempt, and versioned non-secret configuration were completed. The full Gitea webhook, status publication, branch-protection merge gate, and failed-then-repaired pull request were not completed because Jenkins plugin dependencies failed to load and the Jenkins API job-creation attempt was blocked by CSRF/plugin state during follow-up configuration. Those gaps are recorded in Table~\ref{Table:JenkinsRemainingWork} rather than being marked complete.
\end{devopsNote}
\begin{longtable}{L{4.0cm}L{9.2cm}}
\caption{Jenkins Deployment and Persistence Evidence\label{Table:JenkinsDeployment}}\\
\toprule
\textbf{Item} & \textbf{Observed or Configured Value}\\
\midrule
\endfirsthead
\toprule
\textbf{Item} & \textbf{Observed or Configured Value}\\
\midrule
\endhead
\bottomrule
\endlastfoot
Host & Existing DigitalOcean Droplet \texttt{sergio-ssw590-gitea}, public IPv4 \texttt{165.227.90.215}.\\
Capacity before Jenkins & Approximately \texttt{458 MiB} memory, \texttt{8.7 GiB} root filesystem, and no swap.\\
Capacity change & A \texttt{1 GiB} swap file was added at \texttt{/swapfile} to keep Jenkins from exhausting the small Droplet.\\
Jenkins image & \texttt{jenkins/jenkins:2.528.1-lts-jdk21}.\\
Persistent home & Host path \texttt{/opt/jenkins/home} mounted to \texttt{/var/jenkins\_home}.\\
Restart policy & \texttt{unless-stopped} in \texttt{ops/jenkins/compose.yml}.\\
Controller executors & Configured as one controller executor with label \texttt{controller-small-trusted}. This is acceptable only for the small trusted class deployment and should be replaced by a separate agent for untrusted pull requests.\\
Administrator account & Named account \texttt{sespinal-admin}; password stored only on the Droplet under \texttt{/root/jenkins-secrets/admin-password}. The first-boot generated setup password was rotated out of operational use.\\
Restart evidence & Jenkins restarted through Docker Compose and returned \texttt{Jenkins is fully up and running}.\\
\end{longtable}
\section{HTTPS, Access, and Firewall}
Jenkins was not published directly on host port \texttt{8080}. The container exposes \texttt{8080/tcp} only inside Docker networking, and Caddy reverse proxies the public HTTPS hostname to \texttt{jenkins:8080}. Because no \texttt{ci.sespinal590.dev} DNS record existed at the time of implementation, the working Jenkins hostname used for this assignment evidence is \url{https://ci.165.227.90.215.sslip.io/}.
\begin{longtable}{L{4.0cm}L{9.2cm}}
\caption{Jenkins HTTPS and Exposure Checks\label{Table:JenkinsHttps}}\\
\toprule
\textbf{Check} & \textbf{Observed Result}\\
\midrule
\endfirsthead
\toprule
\textbf{Check} & \textbf{Observed Result}\\
\midrule
\endhead
\bottomrule
\endlastfoot
Caddy configuration & Added a second Caddy site block for \texttt{ci.165.227.90.215.sslip.io} with \texttt{reverse\_proxy jenkins:8080}.\\
HTTP behavior & \texttt{http://ci.165.227.90.215.sslip.io/} returned \texttt{308 Permanent Redirect}.\\
HTTPS behavior & \texttt{https://ci.165.227.90.215.sslip.io/} returned \texttt{HTTP/2 403} from Jenkins before login, proving the browser reached Jenkins through Caddy and Jenkins required authentication.\\
Certificate & Caddy obtained a Let's Encrypt certificate for \texttt{ci.165.227.90.215.sslip.io} using the HTTP-01 challenge.\\
Raw Jenkins port & External test to \texttt{ci.165.227.90.215.sslip.io:8080} failed, which is the expected result because port \texttt{8080} is not publicly published.\\
Agent port & Jenkins showed container port \texttt{50000/tcp} internally only; it was not published on the host. No inbound agent port was opened for this assignment.\\
Access control & Jenkins requires login. Additional browser source restriction should be added at Caddy or firewall level before real team use.\\
\end{longtable}
\section{Gitea Trigger and Traceability}
Jenkins and Gitea share the Docker network, so the intended webhook route is private service-to-service traffic from Gitea to Jenkins, while browser traffic reaches Jenkins through Caddy.
\begin{figure}[htbp]
\centering
\fbox{\begin{minipage}{0.88\linewidth}
\centering
\textbf{Team Browser}\\
\texttt{https://ci.165.227.90.215.sslip.io}\\[4pt]
$\Downarrow$\\[4pt]
\textbf{DigitalOcean Cloud Firewall}\\
Public 80/443 only; no public 8080 or 50000\\[4pt]
$\Downarrow$\\[4pt]
\textbf{Caddy Container}\\
TLS termination and reverse proxy\\[4pt]
$\Downarrow$\\[4pt]
\textbf{Jenkins Container}\\
CI controller, trusted small-class executor\\[4pt]
$\Uparrow$\\[4pt]
\textbf{Gitea Container}\\
Future webhook path over the private Docker network
\end{minipage}}
\caption{Jenkins and Gitea integration boundary}
\label{Figure:JenkinsArchitecture}
\end{figure}
The startup repository is \href{https://git.sespinal590.dev/group10-startup/startup-product}{\texttt{group10-startup/startup-product}}. Jenkins was able to reach the repository URL from inside the Jenkins container, and \texttt{git ls-remote} returned commit \texttt{ff266cf} before the Jenkinsfile was added. The Jenkinsfile was then added to the repository as commit \texttt{b0eee02}. A local Gitea filesystem hook issue prevented a normal host-side push, so the operator moved the class repository's branch reference from inside the Gitea container. That action is adequate for a lab setup but is not a substitute for the required pull-request workflow evidence.
\section{Versioned Pipeline and Tests}
The versioned pipeline source is stored in \texttt{ops/jenkins/Jenkinsfile} in this manual repository and was copied into the startup product repository as \texttt{Jenkinsfile}. It contains three stages: checkout, lint, and automated test. The lint step checks for the expected \texttt{README.md} and verifies that it names the startup. The automated test step prints a CI smoke-test marker and lists repository files so the run proves it executed against a real checkout.
\begin{lstlisting}[caption={Jenkinsfile CI stages},label={Listing:JenkinsfileSummary}]
stage('Lint') {
sh 'test -f README.md && grep -qi "startup" README.md'
}
stage('Automated Test') {
sh 'find . -maxdepth 2 -type f | sort | head -20'
}
\end{lstlisting}
\section{Required Merge Gate}
The required merge gate is not yet complete. Gitea branch protection still needs to require the Jenkins status context on pull-request head commits. The exact status context should be the Jenkins job or Gitea Checks context selected after the Jenkins Gitea integration plugin loads successfully. A successful webhook delivery is not enough; the Gitea pull request must show a required check that blocks merge while failing and permits the normal review process after passing.
\section{Failure, Repair, and Review}
The failed-then-repaired pull request sequence remains pending. The required evidence sequence should use one issue-linked pull request and show: failed commit, failed Jenkins run, blocked merge, repair commit, passing run, peer review, and merge. This manual currently does not claim that evidence because no Jenkins status check was successfully published back to Gitea.
\section{Credentials and Build Boundary}
\begin{longtable}{L{4.0cm}L{9.2cm}}
\caption{Jenkins Credentials and Build Boundary\label{Table:JenkinsCredentials}}\\
\toprule
\textbf{Control} & \textbf{Implementation or Required Follow-up}\\
\midrule
\endfirsthead
\toprule
\textbf{Control} & \textbf{Implementation or Required Follow-up}\\
\midrule
\endhead
\bottomrule
\endlastfoot
Jenkins administrator credential & Stored only on the Droplet in \texttt{/root/jenkins-secrets/admin-password}; not committed to Git or printed in this manual.\\
Initial setup password & Jenkins printed a generated first-boot password in container logs. It was replaced operationally by the named admin account and should be rotated again before long-term use.\\
Gitea integration token & Pending. A narrow token should be created for repository read and status/check reporting only.\\
Build location & Builds currently run on the controller because this is a small trusted course deployment. This is a risk: untrusted Jenkinsfile authors could execute commands on the controller.\\
Compensating restriction & Only trusted team members should be able to edit the Jenkinsfile until a separate build agent is deployed and secrets are isolated from untrusted pull requests.\\
\end{longtable}
\begin{longtable}{L{4.0cm}L{9.2cm}}
\caption{Jenkins Plugin Check and Operator Response\label{Table:JenkinsPluginCheck}}\\
\toprule
\textbf{Plugin or Check} & \textbf{Result}\\
\midrule
\endfirsthead
\toprule
\textbf{Plugin or Check} & \textbf{Result}\\
\midrule
\endhead
\bottomrule
\endlastfoot
Installed plugin attempt & \texttt{git}, \texttt{workflow-aggregator}, \texttt{pipeline-stage-view}, \texttt{gitea}, and \texttt{gitea-checks}.\\
Recorded plugin versions & Git \texttt{5.10.1}, Pipeline \texttt{608.v67378e9d3db\_1}, Pipeline Stage View \texttt{2.41}, Gitea \texttt{273.vb\_78d13f6d9a\_d}, and Gitea Checks \texttt{604.638.ve9e5472551b\_3}.\\
Plugin warning & Jenkins reported security advisories for some Pipeline-related plugins during installation.\\
Plugin failure & Jenkins logs reported dependency failures requiring newer \texttt{bouncycastle-api}, \texttt{caffeine-api}, and \texttt{gson-api} plugins. A repair attempt was made, but the failures persisted in the last observed logs.\\
Operator response & The issue was recorded as a blocker. The correct next action is to update the Jenkins base image or reset the plugin catalog/home state, then reinstall plugins and re-run the Gitea check integration.\\
\end{longtable}
\section{Manual Quality and Controls}
\begin{longtable}{L{4.4cm}L{2.0cm}L{6.8cm}}
\caption{Chapter 3 Rubric Evidence Status\label{Table:JenkinsRemainingWork}}\\
\toprule
\textbf{Rubric Criterion} & \textbf{Status} & \textbf{Evidence or Gap}\\
\midrule
\endfirsthead
\toprule
\textbf{Rubric Criterion} & \textbf{Status} & \textbf{Evidence or Gap}\\
\midrule
\endhead
\bottomrule
\endlastfoot
Jenkins deployment and persistence & Partial & Jenkins container, persistent home, restart policy, swap, named admin account, and restart evidence are documented. A longer restart persistence screenshot/check should be captured after browser login.\\
HTTPS, access control, and firewall & Partial & HTTPS, redirect, certificate acquisition, login requirement, and blocked raw port \texttt{8080} are documented. Browser source restriction still needs tightening.\\
Gitea trigger and traceable Jenkins run & Pending & Jenkins can reach the repository, but webhook delivery and matching Jenkins run are not proven.\\
Versioned pipeline with meaningful build and tests & Partial & Jenkinsfile is versioned and committed as \texttt{b0eee02}; Jenkins plugin/API issues blocked the final run evidence.\\
Required Gitea status check and merge gate & Pending & Branch protection and required Jenkins context still need configuration after plugin repair.\\
Failed-then-repaired, reviewed pull request & Pending & No failed/repaired PR sequence has been completed.\\
Credentials, pipeline trust boundary, and plugin operations & Partial & Credentials are not committed; controller-build risk and plugin failures are documented.\\
Versioned IT manual, history, Hosts/Passwords hints, and evidence & Complete for current state & Version 1.7, this history entry, Jenkins host/password controls, deployment artifacts, citations, glossary/index terms, and honest blockers are included.\\
\end{longtable}