Both Jenkins jobs in each environment check out from KIMS's own Git: production's from main, UAT's from uat. This page puts the code there.
#Before you start
- KIMS has created an empty repository and given you push access. Note its URL,
<KIMS_GIT_URL>(for examplehttps://git.kims.example/web/kims-v2.git). - You have the code: a clone of kims-v2, or the git bundle
kims-v2.bundlefrom the handover (workstation/get-the-code). - You know whether KIMS wants UAT (deploy/environments).
Push main, the commit that was handed over (535cdc7 "Runbook: AWS set-up from scratch, Hyderabad region", or later). Do not push the windows-fixes branch: it branched before main's last three commits and lacks the production and UAT model the Jenkins jobs depend on.
#Check what you are about to push
#Step 1: the working copy is clean and on main
The same commands on every system (in PowerShell or a terminal), from the kims-v2 folder:
git switch main
git status --short
git log -1 --onelineExpected: Already on 'main' (or Switched to branch 'main'), no output from git status --short, and one line starting with the commit you mean to deploy, for example 535cdc7 Runbook: AWS set-up from scratch, Hyderabad region.
If you cloned from the bundle, git log -1 shows the bundle's commit. git bundle verify <PATH_TO_BUNDLE> before cloning should end ... is okay.
#Push
#Step 2: add KIMS's repository as a remote
git remote add kims <KIMS_GIT_URL>
git remote -vExpected: two lines for kims, (fetch) and (push), with KIMS's URL. If it says error: remote kims already exists, use git remote set-url kims <KIMS_GIT_URL>.
#Step 3: push main
git push kims mainExpected: ends with * [new branch] main -> main.
In PowerShell, git's progress lines may appear in red, wrapped in NativeCommandError. That is only because git writes progress to the error stream. The push worked if the last line is the [new branch] one.
Git asks for credentials the way KIMS's server needs (a username and a personal access token, or an SSH key). Use your own account, and let Git Credential Manager (Windows, macOS) or your credential helper store it: never put a token inside the URL.
#UAT only: create the uat branch
The uat branch starts as the same commit as main:
git push kims main:uatExpected: * [new branch] main -> uat.
#Check
#KIMS's Git has the same commits
git rev-parse main
git ls-remote kims main uatgit rev-parse main
git ls-remote kims main uatgit rev-parse main
git ls-remote kims main uatExpected: the first command prints a 40-character commit id; the second prints the same id for refs/heads/main (and, with UAT, for refs/heads/uat).
#Line endings survived (Windows)
The repository has a .gitattributes. If you cloned on Windows with core.autocrlf=true, the pushed commits are still normalised, because Git stores what was committed. Nothing to do; but do not commit from a Windows working copy without checking git diff --stat first (workstation/git).
#Later changes
#With UAT
- Push the change to
uat:git push kims <COMMIT>:uat(or merge intouaton KIMS's server). kims-uat/kims-platformdeploys it. KIMS tests it.- Promote:
git push kims uat:main. This only succeeds as a fast-forward. If it is refused withnon-fast-forward, someone committed tomaindirectly: stop and sort it out with KIMS, never force-push. - Run
kims-production/kims-platform(by hand, or by its trigger). It reuses UAT's image of that commit.
#Production only
Push the change to main; kims-production/kims-platform deploys it.
#Which commit is running
kubectl --context <KUBE_CONTEXT> -n <NAMESPACE> get deployment kims-cms -o jsonpath='{.spec.template.spec.containers[0].image}'; echokubectl --context <KUBE_CONTEXT> -n <NAMESPACE> get deployment kims-cms -o jsonpath='{.spec.template.spec.containers[0].image}'; echokubectl --context <KUBE_CONTEXT> -n <NAMESPACE> get deployment kims-cms -o jsonpath="{.spec.template.spec.containers[0].image}"Expected: <REGISTRY>/kims/kims-v2:<40-character commit SHA>. The tag is the commit.
#If it goes wrong
| What you see | Cause | Fix |
|---|---|---|
Permission denied or 403 |
No push access yet | Ask KIMS |
! [rejected] main -> main (fetch first) |
KIMS's repository is not empty | Ask KIMS what is in it. Never force-push over it |
non-fast-forward on uat:main |
main has commits uat lacks |
Find out who committed to main; bring uat up to date with KIMS's agreement |
| SSL certificate problem | KIMS's Git uses an internal certificate authority | Get KIMS's CA certificate and set git config --global http.<KIMS_GIT_URL>.sslCAInfo <PATH_TO_CA_PEM>. Do not turn off SSL verification |
#Sources
kims-v2/docs/ON-SITE-DEPLOYMENT.md(main, step 1 and "After go-live")kims-v2/deploy/jenkins/README.mdkims-v2/deploy/jenkins/Jenkinsfile.platform- https://git-scm.com/docs/git-push
- https://git-scm.com/docs/git-bundle
- https://git-scm.com/docs/git-ls-remote