80.8 Project 74: Approval step before production
Friends, production needs a human gate. Today we add an input step, limit who can approve, timeout the wait, and deploy prod only after yes.
मित्रांनो, production ला human gate हवा. आज input step, approver limit, timeout, आणि yes नंतरच prod deploy.
दोस्तों, production को human gate चाहिए. आज input step, approver limit, timeout, और yes के बाद ही prod deploy.
What you will build in this project
- Add an input approval stage.
- Limit submitter to a group.
- Set a timeout.
- Deploy prod only after approval.
1. Start from a real company story
At Paytm in Noida, an auto-promote pushed a bad config to prod at 2 a.m. with no human check.
Wallet top-ups failed. Rough cost: about ₹1 crore that night.
Vikram added Jenkins input with a 30-minute timeout and two named approvers.
Today we build that gate.
Ravindra Bagale's Tip
Students leave input open forever so jobs pile up. Always set a timeout and abort. Keep that habit.
Students input कायमची खुली ठेवतात. नेहमी timeout आणि abort ठेवा. सवय ठेवा.
Students input हमेशा खुला छोड़ते हैं. हमेशा timeout और abort रखें. आदत रखिए.
2. Start and prepare
Step 1: Why approval
Why: Prod mistakes need a human. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: echo why. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 1: a1
Type this:
echo 'input step pauses the pipeline until a person decides'
You will see:
input step pauses the pipeline until a person decides
What it means: Why.
Example 2: a2
Type this:
mkdir -p /tmp/jen74 && echo 'Today: input, submitter, timeout, prod deploy'
You will see:
Today: input, submitter, timeout, prod deploy
What it means: Scope.
Example 3: a3
Type this:
echo 'Staging stays automatic; prod waits'
You will see:
Staging stays automatic; prod waits
What it means: Split.
Step 2: Input stage
Why: Approve message. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: printf stage. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 4: b1
Type this:
printf '%s\n' ' stage(\'Approve Prod\') {' ' steps {' ' timeout(time: 30, unit: \'MINUTES\') {' ' input message: \'Deploy cart to production?\', ok: \'Deploy\', submitter: \'prod-approvers\'' ' }' ' }' ' }' > /tmp/jen74/INPUT.txt && cat /tmp/jen74/INPUT.txt
You will see:
stage('Approve Prod') {
What it means: Input.
Example 5: b2
Type this:
echo 'ok label is the button text the approver clicks'
You will see:
ok label is the button text the approver clicks
What it means: OK.
Example 6: b3
Type this:
echo 'Without timeout, abandoned runs clog the executor queue'
You will see:
Without timeout, abandoned runs clog the executor queue
What it means: Timeout why.
Step 3: Submitter group
Why: Who can click. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: security realm. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 7: c1
Type this:
printf '%s\n' 'Create Jenkins group or assign users: prod-approvers' 'Only those identities can submit this input' > /tmp/jen74/SUBMITTER.txt && cat /tmp/jen74/SUBMITTER.txt
You will see:
Create Jenkins group or assign users: prod-approvers
What it means: Group.
Example 8: c2
Type this:
echo 'Developers can see the pause but cannot approve if not in the group'
You will see:
Developers can see the pause but cannot approve if not in the group
What it means: Visibility.
Example 9: c3
Type this:
echo 'Use two people for high-risk services when policy asks'
You will see:
Use two people for high-risk services when policy asks
What it means: Four eyes.
3. Build the main pieces
Step 4: Prod deploy stage
Why: After yes. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: deploy. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 10: d1
Type this:
printf '%s\n' ' stage(\'Prod Deploy\') {' ' steps {' ' sh \'kubectl -n shop-prod set image deploy/cart cart=$ACCOUNT.dkr.ecr.$REGION.amazonaws.com/$REPO:$GIT_SHA\'' ' sh \'kubectl -n shop-prod rollout status deploy/cart --timeout=180s\'' ' }' ' }' > /tmp/jen74/PROD.txt && head -5 /tmp/jen74/PROD.txt
You will see:
stage('Prod Deploy') {
What it means: Prod.
Example 11: d2
Type this:
echo 'Use a different kube context or namespace for prod'
You will see:
Use a different kube context or namespace for prod
What it means: Context.
Example 12: d3
Type this:
echo 'Same SHA that passed staging — no rebuild'
You will see:
Same SHA that passed staging — no rebuild
What it means: Same artifact.
Step 5: Reject path
Why: Abort without prod. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: abort tip. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 13: e1
Type this:
echo 'Click Abort on the input form'
You will see:
Click Abort on the input form
What it means: Abort.
Example 14: e2
Type this:
echo 'Pipeline goes red/aborted; Prod Deploy stage must not run'
You will see:
Pipeline goes red/aborted; Prod Deploy stage must not run
What it means: Expect.
Example 15: e3
Type this:
printf '%s\n' 'Acceptance: abort leaves shop-prod image unchanged' > /tmp/jen74/ACCEPT.txt && cat /tmp/jen74/ACCEPT.txt
You will see:
Acceptance: abort leaves shop-prod image unchanged
What it means: Gate.
Step 6: Timeout path
Why: No answer. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: expire. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 16: f1
Type this:
echo 'If nobody clicks within 30 minutes the stage fails'
You will see:
If nobody clicks within 30 minutes the stage fails
What it means: Timeout.
Example 17: f2
Type this:
echo 'Pager tip: notify approvers when input appears'
You will see:
Pager tip: notify approvers when input appears
What it means: Notify.
Example 18: f3
Type this:
echo 'Do not raise timeout to days — that hides stuck releases'
You will see:
Do not raise timeout to days — that hides stuck releases
What it means: Habit.
4. Automate and verify
Step 7: UI and email
Why: Where to approve. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: links. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 19: g1
Type this:
printf '%s\n' 'Open the paused run in Jenkins classic UI' 'Blue Ocean also shows an Approve button' 'Mailer can notify the submitter group' > /tmp/jen74/UI.txt && cat /tmp/jen74/UI.txt
You will see:
Blue Ocean also shows an Approve button
What it means: UI.
Example 20: g2
Type this:
echo 'Mobile: use the Jenkins app or email deep link if enabled'
You will see:
Mobile: use the Jenkins app or email deep link if enabled
What it means: Mobile.
Example 21: g3
Type this:
echo 'Record approver identity in the build log automatically'
You will see:
Record approver identity in the build log automatically
What it means: Audit.
Step 8: Staging before
Why: Still automatic. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: order. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 22: h1
Type this:
printf '%s\n' 'Order: Build -> Push -> Staging Deploy -> Smoke -> Approve Prod -> Prod Deploy' > /tmp/jen74/ORDER.txt && cat /tmp/jen74/ORDER.txt
You will see:
Order: Build -> Push -> Staging Deploy -> Smoke -> Approve Prod -> Prod Deploy
What it means: Order.
Example 23: h2
Type this:
echo 'Never ask for approval before staging smoke is green'
You will see:
Never ask for approval before staging smoke is green
What it means: Order rule.
Example 24: h3
Type this:
echo 'Put the SHA and smoke URL in the input message body'
You will see:
Put the SHA and smoke URL in the input message body
What it means: Message.
Step 9: Milestone tip
Why: Preserve input across restarts. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: milestone. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 25: i1
Type this:
echo 'milestone() before input helps older builds not steal the gate'
You will see:
milestone() before input helps older builds not steal the gate
What it means: Milestone.
Example 26: i2
Type this:
echo 'Disable concurrent builds for prod pipelines if needed'
You will see:
Disable concurrent builds for prod pipelines if needed
What it means: Concurrency.
Example 27: i3
Type this:
echo 'Lockable Resources plugin can serialize prod deploys'
You will see:
Lockable Resources plugin can serialize prod deploys
What it means: Lock.
5. Harden and accept
Step 10: Story Paytm
Why: Noida auto-promote. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: story. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 28: j1
Type this:
printf '%s\n' 'At Paytm in Noida, auto-promote pushed bad config to prod at 2 a.m.' 'Vikram added input with 30-minute timeout and named approvers.' > /tmp/jen74/STORY.txt && wc -l /tmp/jen74/STORY.txt
You will see:
2 /tmp/jen74/STORY.txt
What it means: Story.
Example 29: j2
Type this:
echo 'Rough cost: about ₹1 crore that night'
You will see:
Rough cost: about ₹1 crore that night
What it means: Cost.
Example 30: j3
Type this:
echo 'Vikram: PASS'
You will see:
Vikram: PASS
What it means: Sign-off.
Step 11: Proof
Why: Files. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: ls. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 31: k1
Type this:
ls /tmp/jen74
You will see:
ACCEPT.txt\nINPUT.txt\nORDER.txt\nPROD.txt\nSTORY.txt\nSUBMITTER.txt\nUI.txt
What it means: Tree.
Example 32: k2
Type this:
grep submitter /tmp/jen74/INPUT.txt
You will see:
input message: 'Deploy cart to production?', ok: 'Deploy', submitter: 'prod-approvers'
What it means: Submitter line.
Example 33: k3
Type this:
echo 'Next: Shared libraries project 75'
You will see:
Next: Shared libraries project 75
What it means: Bridge.
Step 12: Acceptance
Why: Prod waits for yes. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.
What: final. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.
Example 34: z1
Type this:
echo 'input with timeout'
You will see:
input with timeout
What it means: Input.
Example 35: z2
Type this:
echo 'submitter group set'
You will see:
submitter group set
What it means: Group.
Example 36: z3
Type this:
echo 'reject leaves prod unchanged'
You will see:
reject leaves prod unchanged
What it means: Reject.
Check yourself
Q1. Who fixed Paytm auto-promote?
Vikram
Q2. Step name?
input
Q3. Timeout example?
30 min
Q4. Prod after?
approval
Q5. Reject touches prod?
no
Q6. Staging auto?
yes
Friends, you gated production with an approval input. Did you understand? Let us try it once more. Reject one run on purpose and prove prod was not touched.
मित्रांनो, तुम्ही production approval input ने gated केली. एक run जाणूनबुजून reject करा आणि prod अस्पर्शित राहिले हे सिद्ध करा.
दोस्तों, आपने production को approval input से gated किया. एक run जानबूझकर reject करें और prod अछूता रहे, यह साबित करें.
Lab: try at home
- Write input stage.
- Configure submitter.
- Timeout and abort.
- Prove reject path.
Recap
- Human gate for prod.
- Named approvers.
- Timeout aborts.
- Staging still auto.
- Reject leaves prod.