KKIMS on-site docs
Jenkins

Jenkins credentials for KIMS v2

Create the environment folder, then every credential the two Jenkinsfiles read (kims-helm-values, kims-site-env, kims-database-url, kims-registry, kims-kubeconfig) with its exact ID, kind and contents.

The Jenkinsfiles read credentials by ID. The IDs are fixed in the code (the site build) or are the default value of a job parameter (the platform job). Each environment keeps its own copy under the same IDs, in its own Jenkins folder, which is how one Jenkinsfile serves production and UAT.

Who does this: KIMS's Jenkins admin creates the folders and enters the credentials, because they hold the database password and registry access. Our engineer prepares the two non-secret files (kims-helm-values and kims-site-env) and checks every ID is spelled exactly.

#Every credential at a glance

ID Kind Read by Fixed or a parameter Where to store it Holds a secret
kims-helm-values Secret file kims-platform Default of HELM_VALUES_CREDENTIALS_ID The environment's folder only No, but it is environment configuration kept out of Git
kims-site-env Secret file kims-site-build Fixed in Jenkinsfile.site The environment's folder only No
kims-database-url Secret text kims-site-build Fixed in Jenkinsfile.site The environment's folder only Yes: the database password
kims-registry Username with password kims-platform Default of REGISTRY_CREDENTIALS_ID; leave the parameter empty to skip Folder, or global if both environments share it Yes
kims-kubeconfig Secret file kims-platform Default of KUBECONFIG_CREDENTIALS_ID; leave the parameter empty to skip Folder (it is scoped to a namespace) It may, depending on how it authenticates
(KIMS's choice) Username with password or SSH key both jobs' Pipeline script from SCM Chosen in the job's SCM settings As KIMS keeps Git credentials Yes
Warning

kims-database-url, kims-site-env and kims-helm-values must never exist as global credentials when UAT and production share one Jenkins. Jenkins looks in the job's folder first and then falls back to global credentials, so a global one lets a job whose folder is missing its own copy use another environment's database or settings without any error.

Note

The kims-jenkins token and the Keycloak client secret are not Jenkins credentials. They are Kubernetes Secrets in the namespace, read by the CMS pods. See Secrets.

#Create the environment folder

Credentials are stored in a folder, so make the folder first. Needs the Folders plugin (Plugins).

  1. From the Jenkins dashboard: New Item.
  2. Enter an item name: kims-production (for UAT: kims-uat).
  3. Choose Folder. OK.
  4. Display Name: leave empty or KIMS v2 production. Save.

You should land on the empty folder's page, at <JENKINS_URL>/job/kims-production/.

If KIMS keeps KIMS v2 inside an existing folder of theirs, that works too: the job URLs just gain another /job/<parent> part, and JENKINS_JOB_URL must include it.

#How to add a credential to the folder

The same steps for every credential below; only the kind and fields differ.

  1. Open the folder (<JENKINS_URL>/job/kims-production/).
  2. In the left menu, Credentials.
  3. Under Stores scoped to kims-production, click kims-production.
  4. Click Global credentials (unrestricted).
  5. Add Credentials (shown as + Add Credentials on newer versions).
  6. Fill the fields as the section for that credential says.
  7. Create (older versions: OK).

Scope: if a Scope field is shown, choose Global. System credentials cannot be used by jobs.

ID: always type it yourself, exactly as below. Left empty, Jenkins makes a random ID and the job will not find it.

#Global instead of folder (only kims-registry and kims-kubeconfig)

Manage Jenkins, Credentials, under Stores scoped to Jenkins click System, Global credentials (unrestricted), Add Credentials. Use this only when both environments truly share the value.

#kims-helm-values

Kind: Secret file. ID: kims-helm-values.

The Helm values for this environment, a filled-in copy of:

Environment Start from
Production deploy/helm/kims/values-production.example.yaml
UAT deploy/helm/kims/values-uat.example.yaml

How to fill it in is on Helm values. Two things matter to Jenkins:

  • Leave KIMS_ENVIRONMENT as the example has it (production or uat). Before helm upgrade, the platform job reads the first KIMS_ENVIRONMENT: line in the file and stops if it is not the environment of the branch it built. So UAT's values can never be deployed from main.
  • It holds no secrets: the database URL, Keycloak client secret, session and secrets keys and the Jenkins token are all read from Kubernetes Secrets named under secretEnv.

Fields:

Field Value
Kind Secret file
File Choose file: your filled-in values-production.yaml
ID kims-helm-values
Description KIMS v2 Helm values, production

Check the file before you upload it:

bash
grep -nE '^[[:space:]]*KIMS_ENVIRONMENT:' values-production.yaml
grep -n '<' values-production.yaml
bash
grep -nE '^[[:space:]]*KIMS_ENVIRONMENT:' values-production.yaml
grep -n '<' values-production.yaml
powershell
Select-String -Path values-production.yaml -Pattern '^\s*KIMS_ENVIRONMENT:'
Select-String -Path values-production.yaml -Pattern '<'

You should see exactly one line KIMS_ENVIRONMENT: production, and no lines with < (every placeholder replaced).

Note

Older notes call this credential kims-helm-values-uat. The code on main uses kims-helm-values in every folder. If an old job still has HELM_VALUES_CREDENTIALS_ID=kims-helm-values-uat, change the parameter back to the default.

#kims-site-env

Kind: Secret file. ID: kims-site-env (fixed in the Jenkinsfile, cannot be changed by a parameter).

The site build's settings for this environment: one NAME=value per line, # for comments. Start from:

Environment Start from
Production deploy/jenkins/site-env-production.example
UAT deploy/jenkins/site-env-uat.example
Variable Production UAT Meaning
KIMS_ENV production uat Required. The first stage stops the build if it does not match the branch (production from main, uat from uat). The quality gates also check robots.txt against it
S3_REGION the buckets' region, for example ap-south-2 same
ASSETS_BUCKET production's assets bucket UAT's Where uploaded media are
WEBSITE_BUCKET production's website bucket UAT's The build owns all of this bucket and deletes what it no longer has
SITE_URL https://<WEBSITE_HOST> https://<UAT_WEBSITE_HOST> The public origin, baked into canonical links and the sitemap
SITE_NOINDEX leave it out true Keeps search engines off. On production it would keep the live site out of Google
CLOUDFRONT_DISTRIBUTION_ID production's distribution UAT's Invalidated after each deploy; unset skips the step
GTM_ID if KIMS uses Google Tag Manager same See Tag Manager
KIMS_REDIRECTS_KVS_ARN only once redirects use a CloudFront KeyValueStore same Unset skips the redirects step

Example layout (production, placeholders not filled):

text
KIMS_ENV=production
S3_REGION=ap-south-2
ASSETS_BUCKET=<ASSETS_BUCKET>
WEBSITE_BUCKET=<WEBSITE_BUCKET>
SITE_URL=https://<WEBSITE_HOST>
CLOUDFRONT_DISTRIBUTION_ID=<DISTRIBUTION_ID>

Rules for the file, because the job loads it with the shell (set -a; eval "$(tr -d '\r' < file)"):

  • No spaces around =. SITE_URL = https://... fails.
  • A value with spaces or shell characters ($, &, ;, quotes) must be in single quotes. None of the normal values need it.
  • Windows line endings are fine: carriage returns are removed first.
  • It holds no secrets. The database password is in kims-database-url, and AWS access is the agent's IAM role.

Check it before uploading:

bash
grep -nE '^KIMS_ENV=' site-env-production
grep -nE ' = |<' site-env-production
bash
grep -nE '^KIMS_ENV=' site-env-production
grep -nE ' = |<' site-env-production
powershell
Select-String -Path site-env-production -Pattern '^KIMS_ENV='
Select-String -Path site-env-production -Pattern ' = |<'

You should see KIMS_ENV=production once, and nothing from the second command.

Fields: Kind Secret file, File your filled-in copy, ID kims-site-env, Description KIMS v2 site build settings, production.

#kims-database-url

Kind: Secret text. ID: kims-database-url (fixed in the Jenkinsfile).

The PostgreSQL connection string for this environment's RDS database. The site build reads the published content through it and writes its progress to the site_builds table, which is what the CMS Builds screen shows. It becomes DATABASE_URL inside the build and is masked in the log.

Format:

text
postgres://<DB_USER>:<DB_PASSWORD>@<RDS_ENDPOINT>:5432/kims?sslmode=require
  • Use the same database and user as the CMS's kims-database Secret (Secrets, RDS).
  • If the password has characters such as @, :, /, ?, # or %, they must be percent-encoded in the URL (for example @ becomes %40). The safest is a password of letters and digits only.
  • Keep ?sslmode=require.

Fields:

Field Value
Kind Secret text
Secret the connection string, typed or pasted by KIMS's admin
ID kims-database-url
Description KIMS v2 database, production
Warning

Do not send the connection string by email or chat to get it into Jenkins. The KIMS admin who knows the password pastes it straight into the Secret field.

#kims-registry

Kind: Username with password. ID: kims-registry. Optional.

Push access to the image registry. The platform job logs in with docker login --password-stdin before the build and logs out after.

Registry What to do
Amazon ECR Do not use this credential. An ECR password from aws ecr get-login-password expires after 12 hours. Give the agent's IAM role the ECR push permissions and install the ECR credential helper (Agent), then set the job parameter REGISTRY_CREDENTIALS_ID to empty
Any other registry (Harbor, Nexus, GitLab, Docker Hub) Create it with a robot or service account's username and token that can push to <REGISTRY>/kims/kims-v2

Fields: Kind Username with password, Username the robot account, Password its token, ID kims-registry, Description KIMS v2 image registry push. Leave Treat username as secret off.

It can be global if production and UAT push to the same registry (they normally do: production reuses UAT's image).

#kims-kubeconfig

Kind: Secret file. ID: kims-kubeconfig. Optional.

A kubeconfig that can deploy to this environment's namespace (kims for production, kims-uat for UAT). Skip it if the agent already has cluster access: then set the job parameter KUBECONFIG_CREDENTIALS_ID to empty, and make sure the agent's user has a working ~/.kube/config.

#Option 1: the agent's own access (no credential)

KIMS's AWS admin adds an EKS access entry for the agent's IAM role (EKS, the cluster, Access, Create access entry, policy AmazonEKSAdminPolicy scoped to the namespace kims, and kims-uat if used). Then, once, on the agent as the agent's user:

bash
aws eks update-kubeconfig --name <CLUSTER_NAME> --region <AWS_REGION>
kubectl -n kims get pods

You should see No resources found in kims namespace. (or the pods), not Forbidden or Unauthorized. See EKS.

#Option 2: a kubeconfig file as the credential

Make the file on a machine with access (your laptop, signed in to AWS), into a new file rather than your own config:

bash
aws eks update-kubeconfig --name <CLUSTER_NAME> --region <AWS_REGION> --kubeconfig ./kims-kubeconfig
grep -n "AWS_PROFILE" -A1 ./kims-kubeconfig
bash
aws eks update-kubeconfig --name <CLUSTER_NAME> --region <AWS_REGION> --kubeconfig ./kims-kubeconfig
grep -n "AWS_PROFILE" -A1 ./kims-kubeconfig
powershell
aws eks update-kubeconfig --name <CLUSTER_NAME> --region <AWS_REGION> --kubeconfig .\kims-kubeconfig
Select-String -Path .\kims-kubeconfig -Pattern "AWS_PROFILE" -Context 0,1

Read the result before uploading it:

  • It runs aws eks get-token on the agent, with the agent's AWS identity. So the agent needs the AWS CLI, and the agent's role still needs an EKS access entry. The file itself contains no password.
  • If the second command finds an AWS_PROFILE entry (added when you ran it with --profile or AWS_PROFILE set), delete that env block: your laptop's profile name does not exist on the agent.
  • Set the namespace in its context if KIMS wants: kubectl config set-context --current --namespace kims --kubeconfig ./kims-kubeconfig.

Fields: Kind Secret file, File kims-kubeconfig, ID kims-kubeconfig, Description KIMS v2 EKS deploy, production. Then delete the local copy.

#The Git credential for checkout

Both jobs use Pipeline script from SCM, so Jenkins needs read access to KIMS's repository. Its ID is not fixed by the code. Use KIMS's existing Git credential if they have one for their Git server, or create one:

  • HTTPS: Username with password (a service account and an access token with read access).
  • SSH: SSH Username with private key (a deploy key with read access).

Choose it in each job's Pipeline, SCM, Credentials field (Platform job).

#Check the credentials

Open the folder, Credentials. You should see each ID in the ID column, once:

Production folder UAT folder
kims-helm-values kims-helm-values
kims-site-env kims-site-env
kims-database-url kims-database-url
kims-registry (unless global or not used) same
kims-kubeconfig (unless not used) same, scoped to kims-uat

Then check Manage Jenkins, Credentials, System, Global credentials (unrestricted) does not have kims-helm-values, kims-site-env or kims-database-url.

The real test is a job run: the platform job's first run and the site job's first run.

#Update a credential later

Open it in the folder's credential list, Update (the spanner icon on older versions). For a Secret file, Choose file again and Save. The next run uses the new value; running builds keep the old one. Updating kims-helm-values does nothing to the cluster until kims-platform runs again.

#If it goes wrong

What you see in the console Likely cause What to do
ERROR: kims-site-env or Could not find credentials entry with ID 'kims-site-env' Not created, misspelled, or created in another folder Create it in this job's folder with the exact ID
Could not find credentials entry with ID 'kims-database-url' Same Same
The Helm values file says KIMS_ENVIRONMENT 'uat', but branch main deploys production The folder holds the other environment's values file Replace kims-helm-values in this folder with this environment's file
This run is for production, which builds only from the 'main' branch, but it checked out 'uat' kims-site-env's KIMS_ENV and the job's branch disagree Fix the file or the job's branch: they must match
No environment set. KIMS_ENV (site build) ... kims-site-env has no KIMS_ENV line Add KIMS_ENV=production (or uat)
Error response from daemon: ... unauthorized at Image Registry credential wrong or expired (an ECR password after 12 hours) For ECR, use the credential helper and an empty REGISTRY_CREDENTIALS_ID
password authentication failed for user in the site build Wrong password in kims-database-url, or special characters not percent-encoded Re-enter it

#Sources

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