Files
Scrap-Web/manual/devopsCI.tex
T
kholmes 5854a35003
Scrap-Web/pipeline/head This commit looks good
manual merge of versions
2026-10-24 10:20:18 +00:00

1126 lines
55 KiB
TeX

\chapter{Continuous Integration with Jenkins}
\ChapterLabel{ContinuousIntegration}
\index{Jenkins}
\index{continuous integration}
\section{Jenkins Deployment and Persistence}
\label{sec:ci-deploy}
Jenkins was deployed on the existing DigitalOcean Droplet used for the Gitea environment. The deployment uses the official Jenkins Docker image, \texttt{jenkins/jenkins}, which specifies the Long-Term Support (LTS) release with Java 21. The running Jenkins instance reported version \texttt{2.580.1} and Java 21.
Jenkins was deployed as a Docker Compose service rather than installed directly on the host operating system. This approach makes the service configuration reproducible and allows the container to be managed independently of the other services running on the Droplet. The Jenkins container is named \texttt{jenkins}.
The Docker Compose configuration defines the Jenkins image, container name, restart policy, Java memory settings, persistent storage, and shared Docker network. The configuration file is located at \texttt{/root/jenkins/docker-compose.yml} on the Droplet. The corresponding source-controlled configuration should be linked here for reproducibility.
The relevant configuration is shown below. It contains no passwords, personal access tokens, or other authentication secrets.
\begin{minted}[fontsize=\small,breaklines,linenos]{yaml}
services:
jenkins:
image: jenkins/jenkins
container_name: jenkins
restart: unless-stopped
environment:
JAVA_OPTS: "-Xms256m -Xmx512m"
volumes:
- jenkins-home:/var/jenkins_home
networks:
- gitea-net
volumes:
jenkins-home:
name: jenkins_home
networks:
gitea-net:
external: true
name: gitea-net
\end{minted}
\noindent\textbf{Configuration file:} \texttt{/root/jenkins/docker-compose.yml} on the Droplet. The source-controlled copy is at \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/deployment/docker-compose.yml}.
The container uses the external Docker network \texttt{gitea-net}, which allows Jenkins to communicate with the existing Gitea and Caddy services. Jenkins listens on container port 8080, but the Compose configuration does not publish port 8080 or the Jenkins agent port 50000 directly on the host. Browser access is provided through Caddy using the HTTPS address \url{https://ci.ssw590-08.me/}.
\subsection{Droplet Capacity and Resource Allocation}
The DigitalOcean Droplet was upgraded to the plan providing 2 GB of RAM, one virtual CPU, and a 50 GB SSD. The host runs Jenkins alongside Gitea and Caddy, so the available resources are shared among these services.
The Jenkins container is configured with the following Java heap limits:
\begin{itemize}
\item Initial Java heap size: 256 MB.
\item Maximum Java heap size: 512 MB.
\end{itemize}
After the Droplet upgrade, the reported host memory usage was approximately 503 MiB used out of 1.9 GiB, with approximately 931 MiB free and 1.4 GiB available. The reported disk usage was approximately 3.3 GB out of 48 GB, leaving approximately 45 GB available. These values describe the host at the time of measurement and may change as builds execute and logs accumulate.
Because the Droplet hosts several services on a relatively small resource allocation, memory and disk usage should be monitored during builds. The Java heap limit helps constrain Jenkins' Java memory allocation, but it does not represent a limit on the container's total memory usage.
\subsection{Persistent Storage and Restart Policy}
Jenkins stores its configuration, job definitions, plugins, and other Jenkins home data under \texttt{/var/jenkins\_home}. The Compose configuration mounts this directory to the named Docker volume \texttt{jenkins\_home}. This separates Jenkins application data from the container's writable filesystem and allows the data to survive replacement or restart of the container, provided that the named volume is retained.
The container uses the Docker restart policy \texttt{unless-stopped}. This policy allows Docker to restart Jenkins after an unexpected container exit and when Docker restarts, unless the container has been explicitly stopped.
The following commands can be used to inspect the running container and verify its storage and restart settings:
\begin{minted}[fontsize=\small,breaklines]{bash}
docker inspect jenkins \
--format 'Restart policy: {{.HostConfig.RestartPolicy.Name}}'
docker inspect jenkins \
--format '{{json .Mounts}}'
docker inspect jenkins \
--format '{{json .HostConfig.PortBindings}}'
\end{minted}
The deployment inspection confirmed the \texttt{unless-stopped} restart policy and the \texttt{jenkins\_home} volume mounted at \texttt{/var/jenkins\_home}. It also confirmed that the container has no host port bindings for Jenkins' internal ports.
\subsection{Container Restart Test}
A container restart test was performed using the following command:
\begin{minted}[fontsize=\small,breaklines]{bash}
docker restart jenkins
\end{minted}
The command completed successfully. Following the restart, Jenkins was accessible through its HTTPS address, and the existing Jenkins configuration and job remained available. This demonstrated that Jenkins could restart without requiring the service to be reinstalled or configured from scratch.
The test also supports the use of the named \texttt{jenkins\_home} volume for persistent Jenkins data. A container restart is not, however, a backup or disaster-recovery test. It does not demonstrate that data can be recovered after volume deletion, disk failure, Droplet loss, or corruption. Separate backups of the Jenkins home data and a documented restoration procedure are necessary to establish recoverability.
\section{HTTPS, Access, and Firewall}
\label{sec:ci-https}
\subsection{Jenkins Login URL and Access Path}
Jenkins is accessible through the following HTTPS address:
\begin{center}
\url{https://ci.ssw590-08.me/}
\end{center}
The hostname \texttt{ci.ssw590-08.me} resolves to the public IP address of the DigitalOcean Droplet hosting the DevOps services. Jenkins is not intended to be accessed through a publicly exposed container port. Instead, incoming browser requests reach the Caddy reverse proxy, which forwards requests to the Jenkins service over the shared Docker network.
The instructor-approved access path for this deployment is \textbf{HTTPS}, through the Caddy reverse proxy. Access was verified by opening the HTTPS login page in a browser on \textbf{[10/23/2026]}.
\subsection{DNS and TLS Certificate}
The DNS record for \texttt{ci.ssw590-08.me} is configured to point to the public IP address of the DigitalOcean Droplet. The hostname is used to distinguish the Jenkins service from the existing Gitea service, which is available at \url{https://git.ssw590-08.me/}.
Caddy serves as the HTTPS reverse proxy for Jenkins. Its configuration includes the following site definition:
\begin{minted}[fontsize=\small,breaklines,linenos]{text}
ci.ssw590-08.me {
encode gzip
reverse_proxy jenkins:8080
}
\end{minted}
Caddy terminates the incoming HTTPS connection and forwards the request to the Jenkins container at \texttt{jenkins:8080} on the shared Docker network. The configuration was validated successfully with \texttt{caddy validate} and subsequently reloaded.
The certificate details should be recorded from the certificate actually presented by the deployed service:
\begin{itemize}
\item \textbf{Hostname:} \texttt{ci.ssw590-08.me}
\item \textbf{Certificate issuer:} Caddy (automatic certificate management)
\item \textbf{Certificate expiration:} January 20, 2027
\item \textbf{Certificate verification date:} October 22, 2026
\end{itemize}
Caddy supports automatic HTTPS certificate provisioning and renewal. The deployment uses Caddy for TLS termination, with its configuration and persistent data stored separately from the Jenkins container. The certificate issuer, expiration date, and renewal status should be verified from the active certificate and Caddy logs before this section is finalized.
\subsection{HTTP-to-HTTPS Redirect and Jenkins Proxy Configuration}
The public web entry point is Caddy, which handles incoming HTTP and HTTPS traffic. The expected browser-facing behavior is that HTTP requests to the Jenkins hostname redirect to HTTPS. This behavior should be documented using a dated test of the deployed endpoint rather than inferred solely from the configuration.
The redirect can be checked from an external machine with:
\begin{minted}[fontsize=\small,breaklines]{bash}
curl -sSI http://ci.ssw590-08.me/
curl -sSI https://ci.ssw590-08.me/
\end{minted}
The first command should be checked for an HTTP redirect to the HTTPS URL. The second verifies the HTTPS response and helps confirm that the endpoint is reachable with TLS.
Jenkins is configured to use the externally accessible URL:
\begin{center}
\url{https://ci.ssw590-08.me/}
\end{center}
This URL should also be configured in Jenkins under \textit{Manage Jenkins} $\rightarrow$ \textit{System} $\rightarrow$ \textit{Jenkins Location}. The configured Jenkins URL must match the public HTTPS address so that generated links and integrations use the correct hostname. Caddy handles the external TLS connection and proxies requests to the Jenkins service internally.
\subsection{Accounts and Authorization}
Jenkins requires authentication to access its administrative interface and configure continuous integration jobs. Access to Jenkins administration and configuration should be restricted to authorized project members.
The Gitea integration uses a dedicated \texttt{jenkins} account and a Gitea Personal Access Token stored in Jenkins credentials. The account has the repository permissions needed for Jenkins to interact with \texttt{SSW-590-08/Scrap-Web}. During integration troubleshooting, repository webhook management initially failed with HTTP 403 responses. The account's repository permissions were subsequently adjusted, and the Jenkins webhook was created successfully in Gitea.
The following account and role information should be completed based on the actual Jenkins security configuration:
\begin{itemize}
\item \textbf{Jenkins administrators:} \texttt{samahk} and \texttt{kaylah7}
\item \textbf{Jenkins users:} \texttt{samahk} and \texttt{kaylah7}
\item \textbf{Gitea integration identity:} \texttt{jenkins}
\item \textbf{Credential storage:} Jenkins Credentials
\end{itemize}
Personal access tokens and passwords are not included in this report. The dedicated integration account should have only the permissions required for repository access, webhook management, and build-status reporting.
\subsection{DigitalOcean Cloud Firewall}
The deployment uses the DigitalOcean Cloud Firewall named \texttt{gitea-firewall}. The firewall controls which inbound connections can reach the Droplet. The intended inbound access includes SSH administration and the public web ports required by Caddy.
The relevant public TCP ports are:
\begin{itemize}
\item \textbf{TCP 22:} SSH administration.
\item \textbf{TCP 80:} HTTP access and HTTPS redirection.
\item \textbf{TCP 443:} HTTPS access through Caddy.
\item \textbf{TCP 222:} Gitea SSH access, where required by the existing deployment.
\end{itemize}
Direct public access to Jenkins on TCP 8080 is not required. The Jenkins container does not publish ports 8080 or 50000 on the Droplet's host network. Likewise, the Gitea web interface is reached through Caddy rather than by exposing its internal TCP port 3000.
The host's UFW firewall was reported as inactive during deployment verification. Consequently, the DigitalOcean Cloud Firewall and Docker's network and port configuration are important parts of the external access restrictions.
The actual Cloud Firewall rules should be captured in a dated screenshot and compared with the rules listed above. Unneeded inbound rules, including direct public access to TCP 3000 and TCP 5432, should be removed if they are not required by another service.
\subsection{Docker Port Mappings}
The Jenkins Compose service joins the existing \texttt{gitea-net} Docker network. It does not define a \texttt{ports} mapping for Jenkins. Inspection of the running container confirmed that Jenkins' internal TCP ports 8080 and 50000 have no host port bindings.
The container's port configuration was inspected with:
\begin{minted}[fontsize=\small,breaklines]{bash}
docker inspect jenkins \
--format '{{json .HostConfig.PortBindings}}'
docker inspect jenkins \
--format '{{json .NetworkSettings.Ports}}'
\end{minted}
The inspection results showed no published host bindings for the Jenkins web interface or agent port. External browser traffic is instead routed through Caddy, which forwards requests to \texttt{jenkins:8080} over the internal Docker network.
This arrangement avoids exposing Jenkins' application port directly to the public Internet and provides a single HTTPS entry point for browser access.
\subsection{External Connectivity Tests}
External tests were performed from a machine outside the Droplet to verify that selected ports were reachable or blocked from the public network. The test results must be recorded with their execution date and the source machine's network context.
The following command tests the public IPv4 address for TCP connectivity:
\begin{minted}[fontsize=\small,breaklines]{bash}
nc -vz -w 3 147.182.179.191 443
nc -vz -w 3 147.182.179.191 8080
\end{minted}
The expected results are:
\begin{itemize}
\item \textbf{TCP 443:} The connection should succeed because Caddy provides the public HTTPS endpoint.
\item \textbf{TCP 8080:} The connection should fail because Jenkins' internal web port is not published on the host and is not intended to be publicly accessible.
\end{itemize}
Previous external tests of TCP ports 3000, 5432, 8080, and 50000 returned connection failures.
\begin{itemize}
\item \textbf{Test date and time:} October 24, 2026, 4:25 AM EDT
\item \textbf{Test source:} Shell on the Droplet itself (\texttt{root@devops-gitea-server}), connecting to its own public IPv4 address
\item \textbf{Droplet IPv4 address:} \texttt{147.182.179.191}
\item \textbf{TCP 443 result:} Succeeded (\texttt{nc} reported the connection to port 443 succeeded)
\item \textbf{TCP 8080 result:} Failed with ``Connection refused,'' so nothing is listening on host port 8080
\end{itemize}
A failed connection alone does not establish which control blocked it. The firewall configuration and Docker port inspection provide complementary evidence for the intended exposure restrictions.
Figure~\ref{fig:ci-port-test} shows the test output. Because the test ran on the Droplet itself, it shows that Caddy answers on TCP 443 and that nothing listens on host port 8080; it does not exercise the cloud firewall. A failed connection alone does not establish which control blocked it. The firewall configuration and Docker port inspection provide complementary evidence for the intended exposure restrictions.
\begin{figure}[H]
\centering
\includegraphics[width=0.85\linewidth]{HW6 images/port-test.png}
\caption{10/24/26 \texttt{nc} test of TCP 443 (succeeded) and TCP 8080 (connection refused) against 147.182.179.191}
\label{fig:ci-port-test}
\end{figure}
\section{Gitea Trigger and Traceability}
\label{sec:ci-trigger}
\subsection{Deployment and Network Paths}
The continuous integration workflow connects the Gitea repository
\texttt{SSW-590-08/Scrap-Web} to Jenkins. The repository is hosted at
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web}, and Jenkins is
accessible through \url{https://ci.ssw590-08.me/}. Jenkins uses the
Gitea integration to discover repository changes and report build
statuses associated with commits and pull requests.
A dedicated Gitea account named \texttt{jenkins} is used for the
integration. A Gitea Personal Access Token is stored in Jenkins'
credential store rather than being embedded in the workflow or
repository files. The account has repository access configured for
\texttt{SSW-590-08/Scrap-Web}. Administrative repository permission
was required to allow Jenkins to manage the repository webhook.
\begin{description}
\item[Repository:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web}
\item[Jenkins job:] \url{https://ci.ssw590-08.me/job/Scrap-Web/}, a
Multibranch Pipeline
\item[Integration account:] \texttt{jenkins-ci}, a dedicated Gitea account
used only by Jenkins
\item[Jenkins credential:] \texttt{gitea-jenkins-ci} (type: Gitea Personal
Access Token)
\end{description}
Jenkins does not use a team member's personal account. The
\texttt{jenkins-ci} account was created by the Gitea site administrator for
this integration and limited to what Jenkins needs:
\begin{itemize}
\item it is a \emph{restricted} account, so it can see only repositories it
is explicitly added to, and it is not a site administrator;
\item it is a collaborator on Scrap-Web only, with \emph{Write} access.
Write is the minimum Gitea requires to set commit statuses. It cannot
push to \texttt{main}, which is protected (Section~\ref{sec:ci-gate});
\item its token, named \texttt{jenkins}, has the scopes
\texttt{write:repository}, \texttt{read:organization}, and \texttt{read:user}. The
token value is stored only in the Jenkins credential store
(Section~\ref{sec:ci-credentials}).
\end{itemize}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{HW6 images/credentials.png}
\caption{Jenkins global credential \texttt{gitea-jenkins-ci} (Gitea Personal Access Token). The token value is concealed and is not reproduced in this manual.}
\label{fig:ci-credential}
\end{figure}
\subsection{Repository and Integration Identity}
\begin{description}
\item[Repository:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web}
\item[Jenkins job:] \url{https://ci.ssw590-08.me/job/Scrap-Web/}, a
Multibranch Pipeline
\item[Integration account:] \texttt{jenkins-ci}, a dedicated Gitea account
used only by Jenkins
\item[Jenkins credential:] \texttt{gitea-jenkins-ci} (type: Gitea Personal
Access Token, global scope)
\end{description}
Jenkins does not use a team member's personal account. The
\texttt{jenkins-ci} account was created by the Gitea site administrator for
this integration and limited to what Jenkins needs:
\begin{itemize}
\item it is a \emph{restricted} account, so it can see only repositories it
is explicitly added to, and it is not a site administrator;
\item it is a collaborator on Scrap-Web only, with \emph{Write} access
(Figure~\ref{fig:ci-collaborators}). Write is the minimum Gitea requires
to set commit statuses. It cannot push to \texttt{main}, which is
protected (Section~\ref{sec:ci-gate});
\item its token, named \texttt{jenkins} and created on October 22, 2026,
has only the permissions \texttt{write:repository} and
\texttt{read:user} (Figure~\ref{fig:ci-token}). The token value is stored
only in the Jenkins credential store (Section~\ref{sec:ci-credentials}).
\end{itemize}
\begin{figure}[H]
\centering
\includegraphics[width=0.85\linewidth]{HW6 images/collaborators.png}
\caption{October 23, 2026 --- Scrap-Web collaborators: the integration
account \texttt{jenkins-ci} and team member \texttt{kholmes}, both with
Write access.}
\label{fig:ci-collaborators}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.7\linewidth]{HW6 images/token-scopes.png}
\caption{October 23, 2026 --- The \texttt{jenkins-ci} account's access
token \texttt{jenkins} and its permissions. Gitea does not display the
token value.}
\label{fig:ci-token}
\end{figure}
\subsection{Webhook Configuration and Delivery}
The Jenkins Gitea integration is configured to communicate with the
Gitea server at \url{https://git.ssw590-08.me/}. The Gitea webhook
connects repository events to the Jenkins service. Jenkins is
reachable externally through Caddy over HTTPS, while the Jenkins
container itself is attached to the shared Docker network
\texttt{gitea-net}. The Caddy reverse proxy forwards requests for
\url{https://ci.ssw590-08.me/} to the Jenkins service on port 8080
inside the Docker network.
The webhook was created in Gitea (\emph{Scrap-Web $\rightarrow$ Settings
$\rightarrow$ Webhooks}) and points at the endpoint exposed by the Jenkins
Gitea plugin. Its details, as shown in
Figures~\ref{fig:ci-webhook-list} and~\ref{fig:ci-webhook-delivery}, are:
\begin{description}
\item[Name:] \texttt{Jenkins Webhook}
\item[Target URL:] \url{https://ci.ssw590-08.me/gitea-webhook/post}, reached
over HTTPS through Caddy
\item[Status:] Listed with a green (healthy) indicator in the repository's
webhook list
\item[Verification:] A \emph{Test Push Event} was sent from Gitea on
October 23, 2026. \emph{Recent Deliveries} lists delivery
\texttt{6b542d91-02b7-45be-a6c2-ba9989df7f4f} with a green check mark,
meaning Gitea delivered the event to the Jenkins endpoint successfully.
\item[Trigger events, content type, and secret:]
\textit{[The webhook triggers on all pushes to main, there's no direct content formed from this, and there is no secret set for the webhook]}
\end{description}
Figure~\ref{fig:ci-job-list} shows the Jenkins job list shortly after the test
delivery: the \texttt{Scrap-Web} Multibranch Pipeline reports a last success
25 seconds earlier, with a last duration of 10 seconds. The Multibranch
Pipeline is also configured to scan the repository periodically as a
fallback; the repository scan log and the matching Jenkins run should be
retained with the webhook delivery record to document the complete trigger
path.
\begin{figure}[H]
\centering
\includegraphics[width=0.9\linewidth]{HW6 images/webhook-list.png}
\caption{\textit{10/23/26} --- Gitea webhook \texttt{Jenkins Webhook} for Scrap-Web, targeting \texttt{https://ci.ssw590-08.me/gitea-webhook/post}.}
\label{fig:ci-webhook-list}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.9\linewidth]{HW6 images/webhook-delivery.png}
\caption{\textit{10/23/26} --- Gitea \emph{Recent Deliveries} for the Jenkins webhook, showing a successful \emph{Test Push Event} delivery.}
\label{fig:ci-webhook-delivery}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.9\linewidth]{HW6 images/jenkins-job-list.png}
\caption{\textit{10/23/26} --- Jenkins job list showing the \texttt{Scrap-Web} Multibranch Pipeline, last success 25 seconds earlier, captured shortly after the test delivery.}
\label{fig:ci-job-list}
\end{figure}
\subsection{Job Configuration and Trigger}
\label{sec:ci-trigger-config}
The Multibranch Pipeline job uses the Jenkins Gitea plugin~\cite{JenkinsGiteaPlugin}
as its branch source, pointed at owner \texttt{SSW-590-08} and repository
\texttt{Scrap-Web} through the \texttt{Gitea} server entry
(\url{https://git.ssw590-08.me}) and the \texttt{gitea-jenkins-ci}
credential (Figure~\ref{fig:ci-branch-source}). Its relevant settings are:
\begin{tabularx}{\linewidth}{L{4.6cm}Y}
\toprule
\textbf{Setting} & \textbf{Value and reason}\\ \midrule
Discover branches & Strategy: \emph{only branches that are not also filed
as PRs}. \texttt{main} is built as a branch; a feature branch with an open
pull request is built once, as that pull request, not twice.\\
Discover pull requests from origin & Strategy: \emph{the current pull
request revision}. Jenkins tests the pull request's actual head commit, so
the tested commit ID matches the one shown in Gitea.\\
Discover pull requests from forks & Strategy: \emph{the current pull
request revision}; Trust: \emph{Nobody}. Fork pull requests are built with
the trusted \texttt{Jenkinsfile} from \texttt{main}
(Section~\ref{sec:ci-credentials}).\\
Build configuration & By \texttt{Jenkinsfile}, script path
\texttt{Jenkinsfile}.\\
Scan repository trigger & Periodically if not otherwise run, every
1 minute.\\
\bottomrule
\end{tabularx}
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{HW6 images/branch-source.png}
\caption{October 23, 2026 --- Branch source settings of the
\texttt{Scrap-Web} Multibranch Pipeline job.}
\label{fig:ci-branch-source}
\end{figure}
\textbf{Trigger: polling fallback.} The job scans Scrap-Web every minute and
starts a build for any branch or pull request whose head commit has changed.
The assignment permits polling in place of a webhook. It was chosen because a
webhook from Gitea to Jenkins on the private container network requires
changing Gitea's allowed webhook hosts, and Jenkins' web interface was not
opened merely to receive webhooks. The cost is a delay of up to one minute
between a push and the start of its build. In practice, each push in
Section~\ref{sec:ci-failure} was built within about two minutes.
Each scan is recorded in the job's \emph{Scan Repository Log}
(Figure~\ref{fig:ci-scan-log}). The scan at 04:15 UTC on October 23, 2026
(00:15 Eastern) found pull request \#13, confirmed that it contains a
\texttt{Jenkinsfile} (``Met criteria''), and recorded its head commit
\texttt{b899233}. Branches and pull requests without a \texttt{Jenkinsfile}
were checked and skipped.
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{HW6 images/scan-log.png}
\caption{October 23, 2026, 04:15 UTC --- Scan Repository Log: pull
request \#13 discovered at commit \texttt{b899233}.}
\label{fig:ci-scan-log}
\end{figure}
\subsection{Build and Commit Traceability}
The Jenkins job is configured as a Multibranch Pipeline using the
Gitea source integration. Jenkins discovers branches and pull
requests from the repository and associates builds with the relevant
revision. This makes it possible to trace a proposed change from its
Gitea pull request to the Jenkins build and its reported status.
During verification, Jenkins logs showed pull-request build activity
for pull request \#13. The logs also showed status notifications for
the following revisions:
\begin{itemize}
\item \texttt{1de58d4742d1ad600dacad50890c845ab963e985}
\item \texttt{84a44f0477dac51b540d038bf3a94b8f49bec275}
\end{itemize}
These revisions were associated with Jenkins status notifications.
The Jenkins log included messages indicating that a pending build
was being reported and that the notification completed. For the
final submission, the commit IDs should be cross-checked against the
corresponding Gitea commit or pull-request pages and the Jenkins
build details.
The traceability path is therefore:
\begin{enumerate}
\item A developer pushes a commit or creates or updates a pull
request in the Gitea repository.
\item Gitea delivers the configured webhook event to the Jenkins
integration.
\item The Jenkins Multibranch Pipeline discovers the relevant
branch or pull-request revision and starts the associated
build.
\item Jenkins records the build result and reports the associated
status back to Gitea.
\item A reviewer can inspect the pull request, commit, and Jenkins
result to determine whether the proposed change passed the
configured checks.
\end{enumerate}
\subsection{Deployment Diagram}
Figure~\ref{fig:gitea-jenkins-deployment} illustrates the deployment
and communication paths between the developer, Gitea, the webhook,
Jenkins, and the repository's build process. The HTTPS browser path
is shown separately from the webhook path to distinguish normal user
access from automated event delivery.
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{figures/gitea-jenkins-deployment.png}
\caption{Deployment and communication paths for Gitea and Jenkins
continuous integration.}
\label{fig:gitea-jenkins-deployment}
\end{figure}
\subsection{Job Configuration and Trigger}
\label{sec:ci-trigger-config}
The Multibranch Pipeline job uses the Jenkins Gitea plugin as its branch
source, pointed at owner \texttt{SSW-590-08} and repository
\texttt{Scrap-Web} through the \texttt{Scrap Gitea} server entry
(\url{https://git.ssw590-08.me}). Its relevant settings are:
\begin{tabularx}{\linewidth}{L{4.6cm}Y}
\toprule
\textbf{Setting} & \textbf{Value and reason}\\ \midrule
Discover branches & Enabled, so \texttt{main} and feature branches appear
in the job.\\
Discover pull requests from origin & Strategy: \emph{the current pull
request revision}. Jenkins tests the pull request's actual head commit, so
the tested commit ID matches the one shown in Gitea.\\
Discover pull requests from forks & Trust: \emph{Nobody}. Fork pull requests
are built with the trusted \texttt{Jenkinsfile} from \texttt{main}
(Section~\ref{sec:ci-credentials}).\\
Build configuration & By \texttt{Jenkinsfile}, script path
\texttt{Jenkinsfile}.\\
Scan repository trigger & Periodically if not otherwise run, every
1 minute.\\
\bottomrule
\end{tabularx}
\textbf{Trigger: webhook with polling fallback.} The Gitea webhook
(Section~\ref{sec:ci-trigger}) notifies Jenkins when a push or pull-request
event occurs, so a build can start without waiting for the next scan. As a
safety net, the job also scans Scrap-Web every minute and starts a build for
any branch or pull request whose head commit has changed. A missed or failed
webhook delivery therefore delays a build by about one minute instead of
losing it. In practice, each push in Section~\ref{sec:ci-failure} was built
within about two minutes.
\subsection{Traceability: Commit to Jenkins Run}
The table below traces one trigger from the commit in Gitea to the Jenkins
run that tested it. The commit ID is the same in Gitea's commit list, in the
run's Checkout log (\texttt{git rev-parse HEAD}), and on the status Gitea
displays for that commit.
\begin{tabularx}{\linewidth}{L{4.2cm}Y}
\toprule
\textbf{Item} & \textbf{Value}\\ \midrule
Event & Repair commit pushed to branch \texttt{feature/issue-11}, the source
of pull request \#13\\
Time pushed & October 23, 2026, 11:07 PM\\
Detected by & Repository scan (polling); build started automatically\\
Pull request & \#13,
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13}\\
Triggering commit & \texttt{84a44f0}\\
Jenkins run & \texttt{Scrap-Web/PR-13} run \#9 (the job was later
removed by Jenkins; see below)\\
Status posted to Gitea & \texttt{Scrap-Web/pipeline/pr-main}: success,
visible on the commit in
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13/commits}{pull
request \#13's commit list}\\
\bottomrule
\end{tabularx}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{HW6 images/pass.png}
\caption{\textit{10/23/26} --- Jenkins stage history for \texttt{Scrap-Web/PR-13}, runs \#1--\#9. Run \#1 failed in the Checkout stage; run \#9 (23:07) passed.}
\label{fig:ci-pr13-history}
\end{figure}
\subsection{Where Checkout and Tests Run}
Checkout, the syntax check, and the tests all run on the Jenkins
controller's built-in node, inside the Jenkins container; the stage view of
each run lists the node as \emph{Jenkins (built-in)}. There is no separate
build agent and no inbound agent port. Jenkins clones the commit from Gitea
over HTTPS into its workspace under \texttt{/var/jenkins\_home/workspace/}
and runs the \texttt{Jenkinsfile} stages there
(Section~\ref{sec:ci-pipeline}). The risk of building on the controller and
the restrictions that limit it are covered in
Section~\ref{sec:ci-credentials}.
\subsection{Failure Diagnoses}
Four integration problems were diagnosed and corrected.
\textbf{Repository not visible to Jenkins.} When the job was first
configured, the Repository list for owner \texttt{SSW-590-08} was empty,
even though the token had repository access. Listing an organization's repositories requires the
\texttt{read:organization} scope, which the first token lacked. A new token
with that scope was generated, the Jenkins credential was updated, and the
old tokens were deleted. After the correction the repository appeared and
the first scan discovered pull request \#13.
\textbf{First build failed: \texttt{python3: not found}.} Run \#1 of
\texttt{PR-13} (October 23, 2026) checked out the commit successfully,
proving the integration worked, but failed in the Checkout stage at
\texttt{python3 --version} with exit code 127. The official Jenkins image
does not include Python. The fix was a deployment change, not a code change:
the Jenkins container is now built from \texttt{jenkins/Dockerfile}, which
adds \texttt{python3} to the recorded Jenkins LTS image. Run \#2 on the same
pull request then passed, reporting Python 3.13.5.
\textbf{Required check reported as missing.} After the status-check
requirement was added, Gitea showed the Jenkins check as green but still
reported ``some required checks are missing'' and blocked the merge.
The branch rule contained a pattern that did
not exactly match the reported context \texttt{Scrap-Web/pipeline/pr-main}.
It was corrected to that exact name.
\textbf{Pull request runs deleted after merge.} Shortly after pull request
\#13 was merged, the \texttt{PR-13} job and all of its runs disappeared from
Jenkins. The Scan Repository Log showed that the job had been removed as an
orphaned item: the pull request was closed, and the Multibranch job's default
orphaned item strategy discards such jobs immediately. Deleted runs cannot be
restored without a backup of \texttt{jenkins\_home}. The evidence survives in
Gitea, because the commit statuses Jenkins posted remain attached to each
commit of pull request \#13. To keep future evidence, the job's
\emph{Orphaned Item Strategy} was changed to keep old items for 30 days.
If a trigger fails in future, the operator follows the procedure in
Section~\ref{sec:ci-troubleshoot}.
\section{Versioned Pipeline and Tests}
\label{sec:ci-pipeline}
\begin{description}
\item[Repository:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web}
\item[Jenkinsfile:]
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/Jenkinsfile}{\texttt{Jenkinsfile} on \texttt{main}}
\item[Application:] \texttt{pricing.py} (repository root)
\item[Tests:] \texttt{tests/test\_pricing.py}
\end{description}
The pipeline tests a small pricing module, \texttt{pricing.py}, using the
optional Python application provided with the assignment. Its function
\texttt{total\_price(unit\_price, quantity)} returns the price of an order and
rejects quantities below one. The module, its tests, and the
\texttt{Jenkinsfile} are committed together at the root of the Scrap-Web
repository, so every \gls{pullrequest} carries the exact code, tests, and pipeline
definition that Jenkins runs.
\subsection{Pipeline Stages}
The \gls{jenkinsfile} is a Declarative Pipeline~\cite{JenkinsPipeline} with three stages. Each
stage fails the run if its command exits with a non-zero code, and later
stages do not run after a failure, so the stage view shows exactly where a
problem occurred.
\begin{tabularx}{\linewidth}{L{2.2cm}L{4.6cm}Y}
\toprule
\textbf{Stage} & \textbf{Command} & \textbf{Purpose and expected result}\\ \midrule
Checkout & \texttt{checkout scm}, \texttt{git rev-parse HEAD} &
Fetches the pull request's head commit from Gitea into the Jenkins
workspace and prints its full commit ID, so the run can be matched to the
commit in Gitea.\\
Syntax check & \texttt{python3 -m py\_compile pricing.py tests/test\_pricing.py} &
Byte-compiles both files. Passes silently; fails on any Python syntax
error before tests are attempted.\\
Test & \texttt{python3 -m unittest discover -s tests -v} &
Runs both unit tests. Expected output ends with \texttt{Ran 2 tests} and
\texttt{OK}; any failing assertion makes the stage, and the run, fail.\\
\bottomrule
\end{tabularx}
\textbf{What the tests check:} \texttt{test\_total} verifies that ten units
at a price of 10 cost 30, which exercises the multiplication.
\texttt{test\_invalid\_quantity} verifies that a quantity of zero raises
\texttt{ValueError}. Changing the multiplication to an addition, as in the
controlled failure in Section~\ref{sec:ci-failure}, makes
\texttt{test\_total} fail with \texttt{AssertionError: 13 != 30}; this was
confirmed locally before the change was pushed.
The full \texttt{Jenkinsfile}:
\begin{minted}[breaklines]{groovy}
pipeline {
agent any
options {
skipDefaultCheckout()
timeout(time: 10, unit: 'MINUTES')
}
stages {
stage('Checkout') {
steps {
checkout scm
sh 'git rev-parse HEAD'
sh 'python3 --version'
}
}
stage('Syntax check') {
steps {
sh 'python3 -m py_compile pricing.py tests/test_pricing.py'
}
}
stage('Test') {
steps {
sh 'python3 -m unittest discover -s tests -v'
}
}
}
post {
success { echo 'All checks passed.' }
failure { echo 'A stage failed: see the stage view for which one.' }
}
}
\end{minted}
\texttt{skipDefaultCheckout()} prevents Jenkins from checking out the code
twice, so the single explicit \texttt{checkout scm} step is the only checkout
and appears as its own stage. The ten-minute timeout stops a hung build from
holding the executor indefinitely.
\subsection{Dependencies}
The application and tests use only the Python 3 standard library
(\texttt{unittest} and \texttt{py\_compile}), so the pipeline downloads no
packages and has no external dependency source to trust or pin. The only
requirement is a \texttt{python3} interpreter on the Jenkins executor,
installed in the Jenkins container image from \texttt{jenkins/Dockerfile}
(Python 3.13.5, as printed by the Checkout stage); it is not installed in the
Gitea container.
\subsection{Reproducing a Clean Run}
\textbf{Locally:} from the root of a fresh clone of the repository, run the
same commands the pipeline runs:
\begin{verbatim}
python3 -m py_compile pricing.py tests/test_pricing.py
python3 -m unittest discover -s tests -v
\end{verbatim}
(On Windows, use \texttt{python} instead of \texttt{python3}.) A clean result
ends with \texttt{Ran 2 tests} and \texttt{OK}.
\textbf{In Jenkins:} every new commit pushed to a pull request starts a new
run in a fresh checkout of that commit. A team member can also rebuild the
same commit from the pull request's branch page in the Multibranch job.
\subsection{Run Evidence}
Figure~\ref{fig:ci-stage-view} shows a passing run, \texttt{Scrap-Web/PR-13}
run \#2 (October 23, 2026, 9:39 PM), on commit \texttt{b899233}, the head of
pull request \#13 at that time (Figure~\ref{fig:ci-scan-log}). The stage view
reports Checkout, Syntax check, and Test as separate results, each passing,
and the run executed on the built-in node (\emph{Jenkins}). The Checkout
stage's log contains the tested commit ID (\texttt{git rev-parse HEAD}) and
the interpreter version, Python 3.13.5. The run pages of pull request \#13
were later removed by Jenkins when the pull request closed
(Section~\ref{sec:ci-trigger}); their results remain as commit statuses in
Gitea.
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{HW6 images/9.2.png}
\caption{October 23, 2026 --- Jenkins stage view of \texttt{Scrap-Web/PR-13}
run \#2 on commit \texttt{b899233}: Checkout, Syntax check, and Test
passed, and the Checkout stage reports Python 3.13.5.}
\label{fig:ci-stage-view}
\end{figure}
\section{Required Merge Gate}
\label{sec:ci-gate}
\subsection{Branch Protection on \texttt{main}}
The default branch, \texttt{main}, is protected in
Gitea~\cite{GiteaProtectedBranches}
(\emph{Scrap-Web $\rightarrow$ Settings $\rightarrow$ Branches},
Figure~\ref{fig:ci-branch-rule}). The rule was created on October 18, 2026,
and the required status check was added on October 23, 2026, once Jenkins
had reported its first status.
\begin{tabularx}{\linewidth}{L{4.6cm}Y}
\toprule
\textbf{Setting} & \textbf{Value and purpose}\\ \midrule
Protected branch & \texttt{main}\\
Direct pushes & Disabled. Every change reaches \texttt{main} through a pull
request, so it passes the same check and review.\\
Required approvals & 1. A teammate other than the author must approve;
Gitea does not allow authors to approve their own pull requests.\\
Dismiss stale approvals & Enabled. A new commit pushed to the pull request
clears earlier approvals, so the final head commit is the one that is
reviewed. This was observed during the demonstration: Gitea automatically
dismissed an earlier approval when commit \texttt{a5180ad} was pushed
(Figure~\ref{fig:ci-pr-fail-fix}).\\
Status check & Enabled. Required context:
\texttt{Scrap-Web/pipeline/pr-main}\\
\bottomrule
\end{tabularx}
The required context was copied from the status Jenkins actually reported on
pull request \#13, not typed in advance. Gitea will not save a status-check
requirement without a pattern, and a pattern that does not match the
reported context exactly leaves the check permanently ``missing'' and blocks
every merge (Section~\ref{sec:ci-trigger}).
\begin{figure}[H]
\centering
\includegraphics[width=0.75\linewidth]{HW6 images/branch-rule.png}
\caption{October 18, 2026 --- Branch protection rule for \texttt{main} in
the Scrap-Web branch settings.}
\label{fig:ci-branch-rule}
\end{figure}
\subsection{How the Status Reaches Gitea}
The merge gate depends on a commit status, not on a trigger. A webhook or
repository scan only tells Jenkins that something changed; it says nothing
about whether the code passes. The sequence is:
\begin{enumerate}
\item A push to a pull request's branch is detected by the Multibranch job's
repository scan (Section~\ref{sec:ci-trigger-config}).
\item The job builds the pull request's latest head commit and runs the
\texttt{Jenkinsfile} stages.
\item When the run starts and again when it finishes, the Jenkins Gitea
plugin~\cite{JenkinsGiteaPlugin} calls the Gitea API with the
\texttt{jenkins-ci} account's token and sets a commit status on that
exact commit: \emph{pending}, then \emph{success} or \emph{failure},
under the context \texttt{Scrap-Web/pipeline/pr-main}.
\item Gitea's branch protection evaluates the statuses on the pull
request's \emph{latest} head commit. The merge is allowed only if that
context is \emph{success} there and the required approval has been
given. A missing, pending, or failed status blocks the merge.
\end{enumerate}
Because the status is attached to a commit, every corrective push creates a
new head commit that has no status until Jenkins tests it again. An earlier
green result cannot be reused for new code.
\subsection{Failed Check Blocks the Merge}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\linewidth]{HW6 images/pr13-fail-fix.png}
\caption{October 23, 2026 --- Pull request \#13 timeline: commit
\texttt{a5180ad} with the failed required check
\texttt{Scrap-Web/pipeline/pr-main} ($\times$), the earlier approval
dismissed automatically, and repair commit \texttt{84a44f0} with the
passing check ($\checkmark$).}
\label{fig:ci-pr-fail-fix}
\end{figure}
\textbf{Links:}
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13}{pull request \#13};
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13/commits}{its
commit list}, where commit \texttt{a5180ad} carries the \emph{failure} status
from Jenkins run \#8. The Jenkins run page itself was removed when the pull
request closed (Section~\ref{sec:ci-trigger}).
\textbf{Expected:} the \texttt{Test} stage fails on commit \texttt{a5180ad},
Jenkins reports \emph{failure}, and Gitea refuses the merge.
\textbf{Actual:} Jenkins run \#8 passed Checkout and Syntax check and
failed at Test with \texttt{AssertionError: 13 != 30}
(Figure~\ref{fig:ci-runs}); the required check on \texttt{a5180ad} was marked
failed (Figure~\ref{fig:ci-pr-fail-fix}), and the pull request could not be
merged while that commit was the head.
\subsection{Passing Check Permits Review and Merge}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\linewidth]{HW6 images/pr13-approved.png}
\caption{October 23, 2026 --- Pull request \#13 at repair commit
\texttt{84a44f0}: required check \texttt{Scrap-Web/pipeline/pr-main}
passed, approved by \texttt{kholmes}, and mergeable.}
\label{fig:ci-merge-allowed}
\end{figure}
\textbf{Links:}
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13}{pull request \#13};
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13/commits}{its
commit list}, where commit \texttt{84a44f0} carries the \emph{success}
status from Jenkins run \#9.
\textbf{Expected:} all three stages pass on commit \texttt{84a44f0}, the
required check turns green, and the merge becomes available once the
required approval is given. \textbf{Actual:} as expected. The check passed,
\texttt{kholmes} approved the final commit, Gitea reported ``All checks were
successful'' and ``This pull request can be merged automatically''
(Figure~\ref{fig:ci-merge-allowed}), and the pull request was merged
(Section~\ref{sec:ci-failure}).
\section{Failure, Repair, and Review}
\label{sec:ci-failure}
\begin{description}
\item[Issue:] \#11,
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/11}
\item[Pull request:] \#13, from \texttt{feature/issue-11} into
\texttt{main}, with \texttt{Closes \#11} in its description:
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13}
\item[Required check:] \texttt{Scrap-Web/pipeline/pr-main}
\end{description}
The controlled failure followed the assignment's example: the multiplication
in \texttt{total\_price} was replaced with an addition on the pull request's
branch, which must make \texttt{test\_total} fail (it expects
$10 \times 3 = 30$ but receives $10 + 3 = 13$). The failure was confirmed
locally before each push. Only the feature branch was changed; the deployed
Gitea and Jenkins services were not touched.
\subsection{Dated Sequence}
All times are October 23, 2026, Eastern Time. Each commit ID below matches
the commit shown in
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13/commits}{pull
request \#13's commit list}, where each commit still carries the status its
Jenkins run reported. Figure~\ref{fig:ci-runs} shows the complete run
history of the \texttt{PR-13} job, captured before Jenkins removed the job
when the pull request closed (Section~\ref{sec:ci-trigger}).
\begin{tabularx}{\linewidth}{L{1.5cm}L{3.3cm}L{1.7cm}L{1.0cm}Y}
\toprule
\textbf{Time} & \textbf{Step} & \textbf{Commit} & \textbf{Run} &
\textbf{Result}\\ \midrule
9:39 PM & First run after Python was installed & \texttt{b899233} & \#2 &
All stages passed\\
11:05 PM & Failing commit pushed (addition) & \texttt{a5180ad} & \#8 &
Test stage failed; check \emph{failure}; merge blocked\\
11:07 PM & Repair commit pushed (multiplication restored) &
\texttt{84a44f0} & \#9 &
All stages passed; check \emph{success}\\
11:10 PM & Peer review & \texttt{84a44f0} & --- &
Approved by \texttt{kholmes}\\
11:12 PM & Merge into \texttt{main} & \texttt{1de58d4} (merge) & --- &
Merged; issue \#11 closed automatically\\
\bottomrule
\end{tabularx}
\begin{figure}[H]
\centering
\includegraphics[width=0.75\linewidth]{HW6 images/pr13-runs.png}
\caption{October 23, 2026 --- Run history of Jenkins job
\texttt{Scrap-Web/PR-13}: run \#1 failed at Checkout (no Python), runs
\#3 and \#8 failed at Test (controlled failures), and runs \#2, \#4, \#6,
\#7, and \#9 passed.}
\label{fig:ci-runs}
\end{figure}
\subsection{Expected Versus Actual Results}
\begin{tabularx}{\linewidth}{L{3.4cm}YY}
\toprule
\textbf{Step} & \textbf{Expected} & \textbf{Actual}\\ \midrule
Failing commit & Syntax check passes; Test fails on
\texttt{test\_total}; check reports \emph{failure} &
As expected: \texttt{AssertionError: 13 != 30} in run \#8\\
Merge attempt & Blocked while the required check fails &
Blocked\\
Repair commit & All three stages pass; check reports \emph{success} &
As expected in run \#9\\
Review & The earlier approval is cleared by the new commits; a fresh
approval is required on the final commit &
Earlier approval dismissed automatically; \texttt{kholmes} approved
\texttt{84a44f0} at 11:10 PM\\
Merge & Allowed only after the passing check and one approval &
Merged at 11:12 PM as \texttt{1de58d4}\\
\bottomrule
\end{tabularx}
\subsection{Earlier Attempt and Corrective Action}
A first failure-and-repair attempt was made earlier the same evening: failing
commit \texttt{ab0bcc2} (run \#3, failed at Test) and repair commit
\texttt{81c343d} (run \#4, passed). While it was in progress, a separate
\texttt{Jenkinsfile} was merged into \texttt{main} through pull request
\#15, so pull request \#13 also showed a merge conflict, and a blocked merge
could not demonstrate the status check alone. The conflict was resolved by
merging \texttt{main} into the branch and keeping the tested
\texttt{Jenkinsfile} (commit \texttt{c5538a8}, run \#6), and stray files
committed by mistake were removed (run \#7). The cycle was then repeated on a
conflict-free branch, producing the sequence above, in which the failed
check is the only reason the merge was blocked.
\section{Credentials and Build Boundary}
\label{sec:ci-credentials}
\subsection{Secret Storage and Scope}
No token or password appears in the repository, the \texttt{Jenkinsfile},
the Compose file, a console log, or this manual. Values are stored only where
listed below; this report names them but never reproduces them.
\begin{tabularx}{\linewidth}{L{3.4cm}L{4.0cm}Y}
\toprule
\textbf{Secret} & \textbf{Stored in} & \textbf{Scope}\\ \midrule
Gitea integration token & Jenkins credential store, global scope, ID
\texttt{gitea-jenkins-ci} (Figure~\ref{fig:ci-credential}) & Belongs to
the dedicated, restricted account \texttt{jenkins-ci}, which is a Write
collaborator on Scrap-Web only. Permissions: \texttt{write:repository} and
\texttt{read:user} (Figure~\ref{fig:ci-token}), enough to read the
repository and set commit statuses.\\
\texttt{jenkins-ci} password & Not stored; used once to create the token &
Hint only in the Passwords table.\\
Jenkins administrator passwords & Jenkins user database (stored hashed) &
One named account per team member; hints only in the Passwords table.\\
\bottomrule
\end{tabularx}
\begin{figure}[H]
\centering
\includegraphics[width=0.7\linewidth]{HW6 images/jenkins-credential.png}
\caption{October 23, 2026 --- The \texttt{gitea-jenkins-ci} credential in
Jenkins 2.580.1. The token is shown only as ``Concealed''.}
\label{fig:ci-credential}
\end{figure}
The pipeline itself uses no secrets: the \texttt{Jenkinsfile} contains no
\texttt{withCredentials} block, and \texttt{checkout scm} uses the job's
configured repository credential automatically without exposing its value to
build steps. A build therefore has nothing secret to print or exfiltrate
through its own steps. If the token is ever exposed, it is revoked in Gitea
(\texttt{jenkins-ci} $\rightarrow$ Settings $\rightarrow$ Applications), a
new one is generated, and the Jenkins credential is updated.
\subsection{Who Can Change What Jenkins Runs}
The \texttt{Jenkinsfile} is code that Jenkins executes, so editing it is
equivalent to running commands on the build host. Only the two team members
can change Scrap-Web: \texttt{samahk13}, the repository owner, and
\texttt{kholmes}, a Write collaborator (Figure~\ref{fig:ci-collaborators}).
The only other account with Write access is \texttt{jenkins-ci}, which
Jenkins uses to read code and post statuses. Because \texttt{main} is
protected (Section~\ref{sec:ci-gate}), a change to the \texttt{Jenkinsfile}
reaches \texttt{main} only through a pull request that passes the check and
is approved by the other team member.
A Multibranch Pipeline builds a pull request using the \texttt{Jenkinsfile}
from that pull request's branch. For pull requests from forks, which could
come from someone outside the team, the job's trust setting is
\emph{Nobody} (Figure~\ref{fig:ci-branch-source}), so Jenkins builds them
with the trusted \texttt{Jenkinsfile} from \texttt{main} rather than the
fork's version. An untrusted contributor therefore cannot make Jenkins run a
modified pipeline on the build host.
\subsection{Where Builds Execute and the Risk}
Builds run on the Jenkins controller's own executor (the built-in node),
inside the Jenkins container; there is no separate build agent. This is
permitted for this assignment~\cite{JenkinsSecurity}, but it carries a
specific risk: build steps run in the same container as Jenkins itself, so a
malicious pipeline could read \texttt{/var/jenkins\_home}, including stored
credentials and job configuration. The compensating restrictions are:
\begin{itemize}
\item only the two team members can author pipeline changes, and
\texttt{main} requires a passing check and review;
\item untrusted fork pull requests cannot replace the \texttt{Jenkinsfile}
and receive no credentials;
\item the Docker socket is not mounted into the Jenkins container: the
Compose file (Section~\ref{sec:ci-deploy}) mounts only the
\texttt{jenkins\_home} volume, so a build cannot control other
containers or the Droplet;
\item the Jenkins web interface is reachable only over HTTPS through Caddy
and requires login (Section~\ref{sec:ci-https}).
\end{itemize}
\subsection{Plugin-Update Check}
On \textit{[date]}, \emph{Manage Jenkins $\rightarrow$ Plugins $\rightarrow$
Updates} listed \textit{[n]} available updates \textit{[name any marked as
security fixes]}. Action taken: \textit{[updated and restarted Jenkins /
deferred until after the assignment, with reason]}. Plugin updates are
checked before each assignment, and any plugin with a published security
warning is updated first.
\subsection{Troubleshooting a Failed Trigger or Build}
\label{sec:ci-troubleshoot}
\textbf{The pull request shows no Jenkins status at all:}
\begin{enumerate}
\item In Jenkins, open the Scrap-Web job's \emph{Scan Repository Log} and
check that the pull request was discovered. Run \emph{Scan Repository
Now} to discover it immediately instead of waiting for the next
one-minute scan.
\item If the scan cannot list the repository, check that the
\texttt{gitea-jenkins-ci} credential holds a current token and that
\texttt{jenkins-ci} is still a Write collaborator
(Section~\ref{sec:ci-trigger}).
\item If a webhook is used: in Gitea, open \emph{Scrap-Web $\rightarrow$
Settings $\rightarrow$ Webhooks}, check \emph{Recent Deliveries} for the
response code, and use \emph{Test Delivery} after any fix.
\end{enumerate}
\textbf{A run exists but failed:}
\begin{enumerate}
\item Open the run's stage view to see which stage failed, then its
console output; the first error message is the one to fix.
\item Checkout fails: check the integration credential and that Jenkins
can reach Gitea. Syntax check or Test fails: reproduce locally with the
commands in Section~\ref{sec:ci-pipeline}.
\item \texttt{python3: not found}: Python is missing from the Jenkins
container. This is a deployment problem, not a code problem.
\item The check is green but Gitea reports it as missing: the branch
rule's status-check pattern does not exactly match
\texttt{Scrap-Web/pipeline/pr-main}; correct the pattern.
\item Runs of a closed pull request have disappeared: the Multibranch
job removed them as orphaned items. Set \emph{Orphaned Item Strategy}
to keep old items (30 days here) and rely on the commit statuses in Gitea
for runs that were already removed.
\item Fix the cause with a new commit on the same branch. The push starts a
new run and a new status on the new head commit. Never weaken the tests
or bypass branch protection to make a merge possible.
\end{enumerate}
\section{Manual Quality and Controls}
\textit{[Version and history entry, Hosts and Passwords table updates, UML
deployment diagram, citations, glossary and index entries, and the operator
restart/troubleshooting note.]}