CI/CD operational runbook — {{PROYECTO_NOMBRE}}
When to use this runbook: a project in phase 2 with a full CD pipeline. If your project is in phase 0, use
RUNBOOK_DEPLOY_MANUAL.md. If it is in phase 1, this runbook does not fully apply yet (there is no CD).Policy: each section one page at most, readable under pressure. No long paragraphs. This is a template.
/hv:cicd-initfills it in with the project's data. The{{placeholders}}— whose names stay as they are, because the wizard substitutes them — are replaced when the real runbook is generated.
1. The build fails in CI
Typical symptoms: dotnet build / npm run build red, tests red, lint error, coverage gate not met (line <70% or branch <60%).
Diagnosis:
- Open the build in the Azure DevOps UI:
{{PIPELINE_URL}} - Scroll to the first red step. Read the last ~30 lines of the log.
- Is it a bug in the code? → fix + commit + push (CI is queued again automatically)
- Is it infrastructure (agent offline, NuGet/npm registry down, disk full)? → see section 5, "Contacts and escalation"
Frequent causes in the organization (in order of likelihood):
- A test that passes locally because it reaches a real
localhost:5000(R12.4) appsettings.Development.jsoncommitted by mistake with real credentials- An absolute path in
vite.config.tspointing at another repository on the developer's filesystem (R12.1) package-lock.jsonout of date with respect topackage.json(you forgot to commit the lockfile afternpm install)- The .NET SDK for the required
<TargetFramework>is not installed on the build agent - Coverage gate not met: line/branch coverage below the threshold (coverage-gate.ps1; exit 3 only with
-Mode block)
Re-queue: after the fix, git push triggers a new CI run. Do NOT queue it by hand from the Azure DevOps UI (see the feedback_no_manual_queue note).
1b. The build does NOT queue after the push (R7)
Symptom: you git push and the build does not even appear in Azure DevOps (it is not failing: it never starts). Typical when the commit only touches deep subfolders (for example docs/testing/**, nested resources).
Cause: a confirmed Azure DevOps Server 2020 bug with trigger.paths.include and settingsSourceType=2 — the '<dir>/**' patterns do not match deep subdirectories (R7). The project's YAML already emits the double pattern '<dir>/**' + '<dir>/**/*' as a defence, but detection is still flaky for very deeply nested paths.
What it is NOT: do not confuse it with "the build is queued but stuck in notStarted/Checkpoint.Authorization" (that is a pool permission, TEC-003, see section 5).
Workaround — queue it by hand over REST (a legitimate exception to the "do not queue by hand" rule, which applies to the normal flow):
# Needs a PAT or --negotiate. Replace {{ADO_COLLECTION_PROJECT_URL}} and definitionId.
$body = @{ definition = @{ id = {{PIPELINE_DEFINITION_ID}} }; sourceBranch = 'refs/heads/{{RAMA_BASE}}' } | ConvertTo-Json
Invoke-RestMethod -Uri "{{ADO_COLLECTION_PROJECT_URL}}/_apis/build/builds?api-version=6.0" `
-Method Post -UseDefaultCredentials -ContentType 'application/json' -Body $body
Underlying fix: make sure the commit also touches a path that DOES trigger (code under {{SRC_DIR}}/), or accept queueing by hand for test-only pushes.
2. The deployment to DEMO fails
Typical symptoms: the Build stage green, the DeployDemo stage red.
DEMO server: {{DEMO_SERVER_FQDN}} (computer name: {{DEMO_COMPUTER_NAME}})
Diagnosis:
- Look at the log of the
IISWebAppDeploymentOnMachineGroup@0step - Typical errors:
Could not find a part of the path '<wwwroot>'→ the path does not exist; ask the infrastructure team to create the IIS siteAccess to the path is denied→ the agent's account (NT AUTHORITY\SYSTEMby convention) lacks permissions; ask the infrastructure teamOne or more files locked→ on in-process ASP.NET Core,TakeAppOfflineFlag: trueis missing (R10). Edit the YAML and re-queue.The remote server returned an error: (401) Unauthorizedin MSDeploy → the agent's credential expired- Smoke test
https://{{DEMO_FQDN}}/...returning 404 or timing out → see "Alternative verification" below
Verification after the fix: the pipeline's own smoke test confirms it (strict for a .NET API, best-effort for an SPA — it emits a warning plus diagnostics without throwing, R11).
Alternative verification by a person (when the best-effort smoke emits a warning): open {{DEMO_URL}} from your browser (NOT from the server — hairpin NAT). If it loads with a 200 and the expected content, the deployment is green even though the automatic smoke could not confirm it.
3. The deployment to PROD fails
Typical symptoms: the DeployProd stage red after the approval gate of the {{PROD_APPROVERS_GROUP}} group.
PROD servers: {{PROD_SERVER_A}} + {{PROD_SERVER_B}} (rolling deploy, two in sequence).
Automatic rollback: if the post-deploy smoke test fails, the job's condition: failed() step restores the pre-deploy backup automatically (R15). The log will say "Rollback executed" and the job ends red. The site is left on the version PRIOR to the deployment.
If the automatic rollback also fails (rare, but documented):
- RDP into the PROD server:
{{PROD_SERVER_FQDN}} - Find the most recent backup:
dir D:\Backups\{{APP_NAME}}\backup-*(sort by date) - Read the marker to confirm the BuildId:
type D:\Backups\{{APP_NAME}}\backup-<BuildId>\_backup-metadata.txt - Stop the app pool:
appcmd stop apppool {{APP_POOL}} - Delete the current wwwroot (preserving
appsettings.Production.json):
pushd C:\inetpub\wwwroot\{{APP_NAME}}
for /f "delims=" %i in ('dir /b /a-d ^| findstr /v /i "appsettings.Production.json web.Production.config"') do del /Q "%i"
- Restore:
xcopy /E /Y D:\Backups\{{APP_NAME}}\backup-<BuildId>\* C:\inetpub\wwwroot\{{APP_NAME}}\ - Start the pool again:
appcmd start apppool {{APP_POOL}} - Check for a 200 from an external browser (NOT from the server, because of hairpin NAT)
- If the second PROD server (
{{PROD_SERVER_B}}) was also affected by the rolling deploy, repeat steps 1-8 there - Tell the team and write a post-mortem in
_hilo/INCIDENTES.md
4. The app is down after a green deployment
Typical symptoms: build green, deployment green, smoke green, but users report 500/503.
Tell them apart:
- Does the app answer
/health/ready? If it does, it is a bug in the app, NOT in the deployment. Hotfix in code. - Is an external dependency down (a reporting engine, the identity provider, SQL Server)? → look at the app's logs; this is not a pipeline problem. Tell the infrastructure team if it is the organization's infrastructure.
- Is a secret empty or badly rotated? → go to the Azure DevOps UI, variable group
{{PIPELINE_NAME}}-secrets, and check the values.
Recycle the pool without going back to the backup (if the app is simply confused by caches or connections):
appcmd recycle apppool {{APP_POOL}}
If none of that works: manual rollback (see section 3).
5. Contacts and escalation
| Kind of problem | Contact | How |
|---|---|---|
| Agent offline / capability misconfigured | The organization's infrastructure team | {{CONTACTO_SISTEMAS}} |
| Azure DevOps permissions (pool, project, environment) | Admin of the configured pool (cicd.buildPool) | {{CONTACTO_ADMIN_POOL}} |
| App or code bug | {{RESPONSABLE_TECNICO}} | Chat / email |
| Secrets and rotations | {{RESPONSABLE_SECRETOS}} (see SECRETOS.md if it exists) | Chat |
| Deciding on a PROD rollback under pressure | {{JEFE_PROYECTO}} + {{RESPONSABLE_TECNICO}} | Chat, ASAP |
6. Backups
- Location:
{{BACKUP_ROOT}}on each target server (typicallyD:\Backups\{{APP_NAME}}\) - Format:
backup-<BuildId>/with_backup-metadata.txtinside (BuildId + BuildNumber + SourceVersion + Timestamp) - Retention: 7 days, automatic (the deploy job's
condition: always()step deletes the old ones, R17) - Builds that reach PROD: mark them "Retain indefinitely" by hand in the Azure DevOps UI, so the pipeline's
retentionRulesdo not delete them - Restoring a specific backup: see section 3, step by step
GitHub Actions equivalents (if cicd.platform = github-actions)
When it generates the runbook, /hv:cicd-init substitutes: the build UI becomes the run ({{PIPELINE_URL}} → https://github.com/<owner>/<repo>/actions/workflows/cd-<slug>.yml); re-queueing is git push (or gh run rerun <id> for the same commit — never "Re-run" a deployment to pro without reading the smoke first); the secrets live in Settings → Environments → <env> → Secrets (gh secret list --env pro), not in a variable group; the "agent" is the runner (gh api repos/<o>/<r>/actions/runners for self-hosted; a hosted one has no state to look at); retention is the artifact's retention-days (raise it to 90 for builds that reach pro); contacts: "GitHub permissions (environments, secrets, runners) → repo admin / organization owner". Rollback (G9): /hv:cicd-deploy --env <env> --tag <previous>.
Runbook generated by /hv:cicd-init. Keep it current: when a new failure scenario shows up, add a section. When a section becomes obsolete, archive it in RUNBOOK_HISTORICO.md.
Fuente: ovillo/_patron/08_CICD/RUNBOOK_TEMPLATE_EN.md