Environments and Promotion
| Environment | Deploys | Gate to enter |
|---|---|---|
| Dev | Every merge to develop or main | Build and unit tests pass |
| Staging / UAT | Every successful build of the release branch | Quality gates, integration tests, smoke test |
| Production | A chosen build, on demand or on schedule | Approval, change window, passing staging, same artifact |
agent noneat the top andinputin a stage without an agent: the waiting approval holds no executorlock(Lockable Resources plugin) stops two pipelines from deploying to the same environment at the same time- Send a ticket or change number with the approval for audit
- Production deploys use dedicated agents with production credentials
Strategy 1: Rolling Update
Replace instances gradually. The default for Kubernetes Deployments and Swarm. Good for most stateless services. Needs backward-compatible versions because old and new run together for a while.
Strategy 2: Blue-Green
Run two identical environments. Blue serves users. Deploy the new version to green, test it privately, then switch traffic at the load balancer or Service selector. Rollback is switching back.
| Pros | Cons |
|---|---|
| Instant switch and instant rollback | Double the resources during the switch |
| Test the real environment before users see it | Databases need care: both versions share data, so changes must be compatible |
Strategy 3: Canary
Send a small share of traffic (1, 5, 25 percent) to the new version, watch metrics, then increase or abort. Needs a smart traffic router: a service mesh, Gateway API weights, an ingress controller with canary support, or Argo Rollouts and Flagger.
Feature Flags
- Deploy code turned off, then enable it for a few users, then everyone, without a new deployment
- Separates deploy (technical) from release (business decision)
- Remember to remove old flags, they become hidden complexity
Database Changes
| Rule | Why |
|---|---|
| Use expand and contract: first add the new column, deploy code that works with both, later remove the old column | Old and new versions run at the same time during a rollout or rollback |
| Never combine a destructive migration with a code deploy | A rollback cannot restore deleted data |
| Run migrations as a separate, tracked step (Flyway, Liquibase, Alembic) | Visible, repeatable, and can be approved on its own |
| Take a backup or snapshot before risky migrations | A way back |
Rollback Plan
| Platform | Rollback |
|---|---|
| Kubernetes Deployment | kubectl rollout undo deployment/NAME |
| Helm | helm rollback RELEASE REVISION |
| Swarm | docker service rollback NAME |
| Server with symlinks | Point the symlink to the previous release and restart |
| Blue-green | Switch traffic back |
| Feature flag | Turn the flag off |
Notifications and Audit Trail
- Record who approved, which ticket, which artifact digest and when (Jenkins keeps the approver in the build log; also write a line to a deployment log or ticket system)
- Add change windows: block production deploys outside agreed hours with a
when { expression { ... } }check or a Jenkins plugin
Practice Tasks
- Create a pipeline with dev, staging and production stages and an approval before production
- Use a lock so two builds cannot deploy to staging at the same time
- Implement a blue-green switch on Kubernetes using two Helm releases and one Service
- Add a failing health check and show an automatic rollback
- Write a rollback pipeline that redeploys an earlier tag
Conclusion
Promote one artifact through dev, staging and production with gates, manual approvals without holding executors, locks and notifications. Choose rolling, blue-green or canary depending on risk, make database changes backward compatible, and always have a practised rollback.

