KKIMS on-site docs
Jenkins

The kims-platform job

Create the kims-platform Pipeline job in the environment's folder from KIMS's Git, set its parameters and trigger, run it the first time, and check what success looks like.

kims-platform turns a commit into a running CMS: it checks the code, builds the one KIMS v2 image, pushes it to KIMS's registry and deploys it to EKS with Helm. One job per environment folder.

Who does this: whoever has rights to create jobs in KIMS's Jenkins (KIMS's admin, or our engineer if KIMS gives the rights). Our engineer gives the settings and watches the first run.

#Before you start

  • The kims-build agent is online with every tool (Agent).
  • The plugins are installed (Plugins).
  • The folder kims-production (or kims-uat) exists with kims-helm-values, and kims-registry / kims-kubeconfig unless the agent has its own access (Credentials).
  • The code is in KIMS's Git: main for production, and uat for UAT (Push the code).
  • The namespace and its four Secrets exist (Secrets). The deploy waits for pods that need them.
  • The registry repository exists, for example kims/kims-v2 in ECR (ECR).

#What the job does, stage by stage

Stage What runs Stops when
Checkout checkout scm; works out the branch and the environment; sets the build's name to #<n> <environment> <first 12 of the commit SHA> REGISTRY is empty, or DEPLOY is ticked on a branch that is neither main nor uat
Install node --version && npm ci npm registry not reachable, wrong Node version
Verify npm run verify (type checks, lint, tests, build checks) Any check fails
Image If <REGISTRY>/<IMAGE_NAME>:<full commit SHA> already exists, reuses it. Otherwise creates the buildx builder kims-builder (first time only) and runs docker buildx build --platform <PLATFORMS> --file deploy/Dockerfile --push Registry login or push fails
Deploy (only if DEPLOY is ticked) Checks the values file's KIMS_ENVIRONMENT against the branch, then helm upgrade --install <HELM_RELEASE> deploy/helm/kims --namespace <namespace> --values <kims-helm-values> --set image.repository=... --set image.tag=<SHA> --wait --timeout 10m, then kubectl rollout status deployment/<HELM_RELEASE>-cms --timeout 5m The values file is the other environment's; the migrate hook fails; pods do not become ready in time

Options set by the Jenkinsfile: one run at a time (disableConcurrentBuilds), a 60 minute timeout, the last 30 builds kept. Nothing else in the job's configuration needs setting for these.

#Create the job

  1. Open the folder: <JENKINS_URL>/job/kims-production/ (UAT: kims-uat).
  2. New Item.
  3. Enter an item name: kims-platform.
  4. Choose Pipeline. OK.
  5. Description: KIMS v2: verify, build the image, deploy to EKS (production).
  6. Triggers (named Build Triggers on older versions): see Choose the trigger.
  7. Scroll to Pipeline. Definition: Pipeline script from SCM.
  8. SCM: Git.
  9. Repository URL: <KIMS_GIT_URL>, the KIMS v2 repository in KIMS's Git.
  10. Credentials: the Git credential (Credentials). The red "Failed to connect to repository" message under the URL must go away once it is chosen.
  11. Branches to build, Branch Specifier: */main for production, */uat for UAT.
  12. Script Path: deploy/jenkins/Jenkinsfile.platform.
  13. Lightweight checkout: leave ticked.
  14. Save.

The job is now at <JENKINS_URL>/job/kims-production/job/kims-platform/.

#Choose the trigger

KIMS decides. The Jenkinsfile sets no trigger itself, so what is set here stays.

Option Set in Triggers Notes
Webhook from KIMS's Git server GitHub hook trigger for GITScm polling, or the GitLab / Bitbucket equivalent from their plugin Fastest. KIMS's Git server must reach Jenkins
Polling Poll SCM, Schedule: H/5 * * * * Checks every 5 minutes. Works when Git cannot reach Jenkins
By hand only nothing ticked Some teams want production deploys started by a person. Then press Build with Parameters after moving main

Production deploys whatever reaches main. With UAT, main only moves after KIMS accepts a commit on uat (Environments), and production's run reuses UAT's image of that commit.

#The parameters

The pipeline declares them. Jenkins learns them on the job's first run; after that, Build with Parameters shows them. Set REGISTRY at least.

Parameter Type Default Set to
REGISTRY String (empty) The registry host, for example <ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.com. No https://, no path
IMAGE_NAME String kims/kims-v2 The repository in the registry
REGISTRY_CREDENTIALS_ID String kims-registry Empty for ECR with the credential helper, or any agent already logged in
PLATFORMS String linux/amd64,linux/arm64 Once KIMS's EKS node architecture is known, just that one (for example linux/amd64) to build in about half the time
KUBECONFIG_CREDENTIALS_ID String kims-kubeconfig Empty when the agent has its own cluster access
HELM_VALUES_CREDENTIALS_ID String kims-helm-values Leave it
HELM_RELEASE String kims Leave it. Pod, Deployment and Job names start with it (kims-cms, kims-worker, kims-migrate)
NAMESPACE String (empty) Leave empty: production gets kims, UAT gets kims-uat. Set it only if KIMS uses another namespace
DEPLOY Boolean ticked Untick to build and push without deploying

#Make the defaults stick

A value typed into Build with Parameters applies to that run only. To change a default for every run (for example REGISTRY, or empty REGISTRY_CREDENTIALS_ID), the Jenkinsfile's defaults would be used again on the next run, because a Declarative pipeline rewrites its parameter definitions each time it runs. So:

  • For a webhook or polling trigger, which passes no values, the Jenkinsfile's defaults are what run. An automatic run fails at Checkout with "Set the REGISTRY parameter" because REGISTRY has no default in the code.
  • The way round, without a code change: run by hand with Build with Parameters, or ask us for a change that reads the registry from the values file. Raise this with KIMS before relying on automatic deploys.
Warning

This is a gap in the code as it stands: an automatic (webhook or polling) run of kims-platform has no way to get REGISTRY and stops at Checkout. Until it is changed, start kims-platform with Build with Parameters.

#The branch guard

The Checkout stage takes the environment from the branch it built:

Branch Environment Default namespace
main production kims
uat uat kims-uat
anything else none none: with DEPLOY ticked the run stops with Branch '<name>' deploys nowhere: production deploys from main, UAT from uat. Untick DEPLOY to only build it.

Then the Deploy stage reads KIMS_ENVIRONMENT from the folder's kims-helm-values file and stops if it differs:

text
The Helm values file says KIMS_ENVIRONMENT 'uat', but branch main deploys production. Check the kims-helm-values credential in this folder.

This is what stops UAT's database and buckets being deployed into production.

#First run

  1. Open the job. The first time there is only Build Now (Jenkins does not know the parameters yet).
  2. Build Now. This run stops at Checkout with Set the REGISTRY parameter to KIMS's image registry. That is expected: it teaches Jenkins the parameters.
  3. Refresh the page. Build with Parameters is now there.
  4. Build with Parameters: fill REGISTRY, empty REGISTRY_CREDENTIALS_ID and/or KUBECONFIG_CREDENTIALS_ID if the agent has its own access, leave the rest. Build.
  5. Open the run, Console Output (or Pipeline Overview / Stages) and follow it.

The first run takes longest: npm ci with an empty npm cache, the buildx builder being created, and both architectures built from scratch. Later runs reuse the caches.

#What success looks like

  • Every stage green.
  • The run's name: #2 production 535cdc7xxxxx (the environment and the first 12 characters of the commit).
  • The end of the console: Deployed <REGISTRY>/kims/kims-v2:<full SHA> to production (namespace kims) and Finished: SUCCESS.
  • In the registry, the tag <full SHA> with both architectures (or the one in PLATFORMS).

#Check the cluster

From a machine with access to the cluster (kubectl and Helm, EKS):

bash
kubectl -n kims get pods,jobs,cronjobs
helm -n kims history kims
bash
kubectl -n kims get pods,jobs,cronjobs
helm -n kims history kims
powershell
kubectl -n kims get pods,jobs,cronjobs
helm -n kims history kims

You should see kims-cms-... and kims-worker-... pods Running with READY 1/1, the kims-migrate Job Complete (or already removed by Helm's hook policy), one CronJob per scheduled task, and a Helm revision with STATUS deployed and the chart description Install complete or Upgrade complete.

Then the readiness check:

bash
kubectl -n kims port-forward svc/kims-cms 3000:80 &
sleep 2
curl -s "http://localhost:3000/api/health?check=ready"; echo
kill %1
bash
kubectl -n kims port-forward svc/kims-cms 3000:80 &
sleep 2
curl -s "http://localhost:3000/api/health?check=ready"; echo
kill %1
powershell
$pf = Start-Process kubectl -ArgumentList "-n","kims","port-forward","svc/kims-cms","3000:80" -PassThru -WindowStyle Hidden
Start-Sleep -Seconds 2
curl.exe -s "http://localhost:3000/api/health?check=ready"
Stop-Process -Id $pf.Id

You should see {"status":"ready","database":"ok"}. More checks are on First deploy.

#Run it again later

  • New code: happens on its own by the trigger (subject to Make the defaults stick), or Build with Parameters.
  • Same commit again (for example after changing kims-helm-values): Build with Parameters. The image already exists, so the Image stage prints <image> is already in the registry; deploying it as it is. and only the Deploy stage does real work.
  • Build an image without deploying: untick DEPLOY.

#Roll back

Two ways, both on Day two:

  1. Rerun on an earlier commit. In KIMS's Git, the branch must point at that commit (Jenkins builds the branch head). The image for that commit is still in the registry, so it deploys at once.
  2. Helm rollback from a machine with cluster access, then let the next normal deploy move forward again:
bash
helm -n kims history kims
helm -n kims rollback kims <REVISION>
bash
helm -n kims history kims
helm -n kims rollback kims <REVISION>
powershell
helm -n kims history kims
helm -n kims rollback kims <REVISION>
Warning

A rollback does not undo database migrations. Migrations are written to be backward compatible, but check with us before rolling back across a release that added migrations.

#If it goes wrong

Where it stops What you see Likely cause What to do
Checkout Set the REGISTRY parameter to KIMS's image registry. First run, or a triggered run Expected on the first run. Later: Build with Parameters with REGISTRY
Checkout Branch '<name>' deploys nowhere The job's Branch Specifier is not */main or */uat Fix the specifier, or untick DEPLOY to only build
Checkout Failed to connect to repository or Authentication failed Git credential missing or no network to KIMS's Git Fix the job's SCM credential; check the agent reaches Git
Install EBADENGINE, npm ERR! network Wrong Node, or no npm registry access Agent
Verify A test or type check fails A real code problem, or a broken checkout Read the first error in the log; tell us
Image ERROR: failed to solve ... unauthorized / denied No push access ECR: the agent role's ECR permissions and the credential helper; others: kims-registry
Image permission denied while trying to connect to the Docker daemon socket Agent user not in docker group Agent
Deploy The Helm values file says KIMS_ENVIRONMENT ... The folder holds the other environment's values file Replace kims-helm-values
Deploy Kubernetes cluster unreachable or Unauthorized No kubeconfig, expired credentials, or no EKS access entry for the agent role Credentials: kims-kubeconfig
Deploy pre-upgrade hooks failed / job failed: BackoffLimitExceeded The migrate Job failed (database unreachable, wrong URL) kubectl -n kims logs job/kims-migrate; the running version stays up
Deploy timed out waiting for the condition Pods not ready within 10 minutes kubectl -n kims describe pod <pod> and its events: image pull, missing Secret, readiness check

More in Jenkins troubleshooting.

#Sources

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