KKIMS on-site docs
Local rehearsal

Local Jenkins and the site build job

Start a local Jenkins with the build tools and plugins built in, set up the kims-site-build job with its parameters and its two credentials, run a build by hand, and let the local CMS start builds on publish.

A local stand-in for KIMS's Jenkins, with the build agent's tools built in. You set up the kims-site-build job in it exactly as KIMS's Jenkins will have it, then run the real deploy/jenkins/Jenkinsfile.site. This is practice for the Jenkins pages (Site build job), and lets the site build run in Linux even when your laptop is Windows.

The local Jenkins runs only the site build job. The platform job (build the image, deploy with Helm) is rehearsed on kind and Helm instead: the local Jenkins has no Docker, Helm or registry.

#What you get

local/jenkins/Dockerfile builds an image from jenkins/jenkins:lts-jdk21 with:

  • Node.js 24 (24.19.0), for amd64 or arm64.
  • Chromium, for the Lighthouse gate (CHROME_PATH=/usr/bin/chromium).
  • git.
  • The plugins the two Jenkinsfiles use: workflow-aggregator, git, timestamper, credentials-binding, plain-credentials.

local/docker-compose.yml runs it as the jenkins service, only with --profile jenkins:

Setting Value Why
Address http://localhost:8190 Container port 8080
Setup wizard Off, and security off A local copy only
The repo Mounted read-only at /repo The job checks out file:///repo, as KIMS's job checks out their Git. ALLOW_LOCAL_CHECKOUT is on
Site settings ASSETS_BUCKET, WEBSITE_BUCKET, S3_ENDPOINT=http://s3:8333, S3_REGION, S3_FORCE_PATH_STYLE, the stand-in's keys, SITE_URL, SITE_NOINDEX=true, KIMS_ENV=local Stand-ins for what KIMS keeps in the kims-site-env credential
Jenkins home Docker volume kims-v2_jenkins-home Jobs, credentials and history survive restarts
Build workspace On main: the folder .local-jenkins-workspace in the repo. On windows-fixes: the Docker volume kims-v2_jenkins-workspace A full build needs about 10 GB there
Warning

On main the workspace is a folder on your disk, shared into the container. On Windows (and likely on macOS, where Docker Desktop shares folders the same way) npm ci, Next's write-out and the language merge spent most of a 90-minute build on file I/O, and the build timed out. The windows-fixes commits, not yet merged into main, move the workspace to a Docker volume, which fixed it. On Linux, a folder is as fast as a volume.

The Compose file reads the branch you have checked out when you start Jenkins. The job itself builds whatever branch you point it at (step 5).

#Before you start

  • The services are up and the database is loaded: Services, Database and content.
  • The code you want built is committed in the repo. Jenkins checks it out with git, so uncommitted changes are not built.
  • About 10 GB free where the workspace lives (Docker's disk with windows-fixes, your own disk on main), and internet access for the first image build (Debian packages, nodejs.org, the Jenkins plugin site) and for npm ci.

#Quick way

Run from <KIMS_FOLDER>:

bash
node deployment-steps/scripts/deploy.mjs local jenkins up
bash
node deployment-steps/scripts/deploy.mjs local jenkins up
powershell
node deployment-steps/scripts/deploy.mjs local jenkins up

It builds the image the first time (about 5 minutes), starts Jenkins, waits until it answers, and checks the five plugins and Node.js, Chromium and git inside the container. It ends OK: Jenkins is up at http://localhost:8190. A second run takes seconds. --rebuild rebuilds the image after the Dockerfile changes.

The job and its credentials (steps 3 to 5) are set up in Jenkins's own screens; there is no command for them.

#Start Jenkins

#1. Start the service

Run from the repo:

bash
docker compose -f local/docker-compose.yml --profile jenkins up -d --wait jenkins
bash
docker compose -f local/docker-compose.yml --profile jenkins up -d --wait jenkins
powershell
docker compose -f local/docker-compose.yml --profile jenkins up -d --wait jenkins

The first time it builds the image, then ends Container kims-v2-jenkins-1 Started. Open http://localhost:8190: no wizard, no sign-in.

#2. Let git read the mounted repo

The repo's files inside the container may belong to another user than jenkins, and git then refuses the repo as "dubious ownership": the job's Repository URL shows Failed to connect to repository. Mark it safe. Run from the repo:

bash
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git config --global --add safe.directory /repo/.git
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git config --global --add safe.directory /repo
bash
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git config --global --add safe.directory /repo/.git
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git config --global --add safe.directory /repo
powershell
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git config --global --add safe.directory /repo/.git
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git config --global --add safe.directory /repo

They print nothing. Then check:

bash
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git ls-remote -- file:///repo refs/heads/main
bash
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git ls-remote -- file:///repo refs/heads/main
powershell
docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git ls-remote -- file:///repo refs/heads/main

You should see a commit id and refs/heads/main. The setting is saved in Jenkins's home volume, so it lasts until a reset.

Warning

On Windows run these from PowerShell, not Git Bash: Git Bash rewrites /repo into a Windows path before Docker sees it.

#Set up the job

#3. Set Jenkins's own URL

In Jenkins: Manage Jenkins, System, Jenkins Location, Jenkins URL: http://localhost:8190/. Save.

The site build stores a link to its Jenkins run (BUILD_URL), which is built from this URL.

#4. Add the two credentials

Jenkinsfile.site on main reads two credentials. In Jenkins: Manage Jenkins, Credentials, System, Global credentials (unrestricted), Add Credentials.

The database:

Field Value
Kind Secret text
Secret postgres://kims:<LOCAL_DB_PASSWORD>@postgres:5432/kims, with the password from DATABASE_URL in .env.local
ID kims-database-url

The host is postgres and the port 5432, not 127.0.0.1:5418: Jenkins runs on the same Docker network as Postgres.

The site settings: first make a text file, for example site-env-local.txt, outside the repo, holding one line:

text
KIMS_ENV=local

Then add it:

Field Value
Kind Secret file
File site-env-local.txt
ID kims-site-env

The job's first stage, Check environment, reads KIMS_ENV from this file and runs deploy/jenkins/check-environment.sh. local has no branch rule; production must build from main and uat from uat. The other settings (buckets, SITE_URL and so on) come from the container's environment here, so the file needs nothing else. Windows line endings in it are fine: the job drops carriage returns.

Note

On KIMS each environment has its own Jenkins folder (kims-production, and kims-uat if they have UAT) with its own kims-database-url and kims-site-env credentials. Never add them as global credentials there: one global pair would be shared by UAT and production. Locally there is only one environment, so global is fine. See Jenkins credentials.

Note

A windows-fixes checkout has an older Jenkinsfile.site without the Check environment stage, so it needs only kims-database-url. Adding kims-site-env anyway does no harm.

#5. Create the kims-site-build job

In Jenkins: New Item, name kims-site-build, Pipeline, OK. Then:

  1. Tick This project is parameterized and add three String Parameters:

    Name Default value
    PUBLISH_VERSION (empty)
    CAUSE manual
    TRIGGER_ACTOR (empty)

    A Pipeline job learns its parameters from the Jenkinsfile only after its first run. Until then Jenkins answers HTTP 400 to the CMS's buildWithParameters, which is why they are added by hand. This is the same on KIMS.

  2. Under Pipeline: Definition Pipeline script from SCM, SCM Git, Repository URL file:///repo, Branch Specifier */main, Script Path deploy/jenkins/Jenkinsfile.site.

  3. Save.

#Run it

#6. Run a build by hand

Open kims-site-build, Build with Parameters: PUBLISH_VERSION the newest version (Site build finds it; 1 after the first load), CAUSE manual. Build.

It runs Check environment (Environment: local (no branch rule)), Install (npm ci), then Build and deploy: the same site build as Site build, into the kims-website bucket. It archives gate-results.json. Expect around 20 minutes with the workspace on a Docker volume. It should end SUCCESS, and the CMS's Builds screen should show it as succeeded, with a link to the Jenkins run.

#See the built site from a Jenkins build

The build is in Jenkins's workspace, not in apps/website/dist. Copy it out, then serve it as on Site build. Run from <KIMS_FOLDER>. Delete the old copy first: if the folder exists, docker cp puts the new copy inside it as dist.

bash
rm -rf jenkins-site-dist
docker cp kims-v2-jenkins-1:/var/jenkins_home/workspace/kims-site-build/apps/website/dist jenkins-site-dist
python3 -m http.server 8080 --bind 127.0.0.1 --directory jenkins-site-dist
bash
rm -rf jenkins-site-dist
docker cp kims-v2-jenkins-1:/var/jenkins_home/workspace/kims-site-build/apps/website/dist jenkins-site-dist
python3 -m http.server 8080 --bind 127.0.0.1 --directory jenkins-site-dist
powershell
Remove-Item -Recurse -Force jenkins-site-dist -ErrorAction SilentlyContinue
docker cp kims-v2-jenkins-1:/var/jenkins_home/workspace/kims-site-build/apps/website/dist jenkins-site-dist
python -m http.server 8080 --bind 127.0.0.1 --directory jenkins-site-dist

It copies about 4 GB. Open http://localhost:8080/. On main, where the workspace is the repo's .local-jenkins-workspace folder, you can serve .local-jenkins-workspace/kims-site-build/apps/website/dist directly instead.

#7. Let the CMS start builds (optional)

So a publish in the CMS on 3101 starts a build on its own, as it will on KIMS. The CMS needs a Jenkins user with an API token, so security must be on first:

  1. Manage Jenkins, Security: Security Realm Jenkins' own user database, Authorization Logged-in users can do anything. Save, then create your own admin account when asked.

  2. Manage Jenkins, Users, Create User: for example kims-cms. Sign in as it, open its Security page, API Token, Add new Token, Generate, and copy the token. It is shown once.

  3. Add three lines to .env.local in the repo (the token stays only in that file):

    text
    JENKINS_JOB_URL=http://localhost:8190/job/kims-site-build
    JENKINS_USER=kims-cms
    JENKINS_TOKEN=<JENKINS_API_TOKEN>
  4. Restart the CMS and the worker (Run the apps). Publish something in the CMS: the Builds screen should show a build start in Jenkins.

The worker calls POST <JENKINS_JOB_URL>/buildWithParameters with HTTP basic auth (user and token); an API token needs no CSRF crumb. On KIMS, JENKINS_JOB_URL includes the environment's folder, for example https://<JENKINS_HOST>/job/kims-production/job/kims-site-build. Testing the token with curl is on Jenkins API token.

Note

Once security is on, deploy.mjs local jenkins up can no longer list the plugins (Jenkins answers 403). It says so and still checks the tools in the container.

#Check

Check Command or place You should see
Jenkins answers curl -s -o /dev/null -w "%{http_code}" http://localhost:8190/api/json (Windows: curl.exe, -o NUL) 200 (or 403 once security is on)
The tools in the container docker compose -f local/docker-compose.yml --profile jenkins exec -T jenkins node --version (also chromium --version, git --version) v24.19.0, a Chromium version, a git version
The job's last build Jenkins, kims-site-build SUCCESS
The build record The CMS's Builds screen The build, succeeded, with a Jenkins link

#If it goes wrong

What you see Likely cause What to do
The image build fails downloading something No internet for apt, nodejs.org or the plugin site Check the network, then deploy.mjs local jenkins up --rebuild
Failed to connect to repository with detected dubious ownership in repository at '/repo/.git' git refuses a repo owned by another user Step 2
Checkout fails on file:///repo for another reason Jenkins not started from the Compose file, so no mount or no local checkout Start it as in step 1
ERROR: Could not find credentials entry with ID 'kims-site-env' The main Jenkinsfile needs it Step 4
Check environment: No environment set or Unknown environment kims-site-env has no or a wrong KIMS_ENV Make it KIMS_ENV=local
The job fails at Install No access to the npm registry from the container Check the network
The job fails connecting to the database The credential points at 127.0.0.1:5418 Use postgres:5432 (step 4)
The build times out at 90 minutes (Windows or macOS, main) Workspace on a shared folder Use windows-fixes (workspace on a volume), or run the build on the host (Site build) on Linux or macOS
ENOMEM in Build locales Too many build workers for Docker's memory Give Docker Desktop more memory; windows-fixes sets KIMS_BUILD_WORKERS=3 here
The CMS's build request gets HTTP 400 The job's parameters aren't defined yet Step 5, or run one build first
HTTP 401 or 403 Wrong user or token, or security is off Step 7
No build starts after a publish JENKINS_JOB_URL not set, or the worker not restarted Step 7

More in Jenkins troubleshooting.

#Sources

Built 2026-11-29. Commands are shown for the system picked at the top; every block has all three.