Bootstrapping a Controller

Bootstrapping a Fresh Controller from a Casc File

The image pins the core and a plugins.txt (plugins.txt) that adds configuration-as-code and job-dsl:

ci/jenkins/DockerfileDockerfile
# BookNest's Jenkins controller: pinned core and plugins; configuration comes from casc.yaml
FROM jenkins/jenkins:2.568.3-lts-jdk21
ENV JAVA_OPTS=-Djenkins.install.runSetupWizard=false \
    CASC_JENKINS_CONFIG=/var/jenkins_conf/casc.yaml
COPY --chown=jenkins:jenkins plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli --plugin-file /usr/share/jenkins/ref/plugins.txt

The container gets an empty volume, the ci/jenkins checkout read-only, and the two secret files:

Building the image and starting a controller from nothingShell
cd ci/jenkins
docker build -q -t l2-jenkins-casc:2.568.3 .
docker run -d --name l2-jenkins-casc --network l2-jenkins-net -p 127.0.0.1:32081:8080 \
  -v l2-jenkins-casc-home:/var/jenkins_home \
  -v "$PWD":/var/jenkins_conf:ro \
  -v /home/dev/v5-ch5/casc-secrets:/run/secrets:ro \
  l2-jenkins-casc:2.568.3

Built in 45 seconds, it served its login page 29 seconds after docker run, with the admin user, credential, node, library and job in place:

The CasC controller's dashboard: the system message, a generated job whose first build waits for an agent
The CasC controller's dashboard: the system message, a generated job whose first build waits for an agent

The first build of main waits in the queue with "There are no nodes with the label ‘docker’", and agent-1 is offline because nothing runs its container: JCasC 2,791 recreates the controller, not the machines around it. An unknown key is rejected, not guessed (the export's unknown: "reject"): try changes on a throwaway controller first.