Deploying with GoCD
Continuous delivery server with value stream maps and pipeline-as-code.
CI/CDIntermediate
Why
GoCD visualizes the entire delivery pipeline as a value stream map, making bottlenecks and dependencies obvious. DORA's 2024 State of DevOps report shows elite teams deploy 973x more frequently than low performers.
CI/CD pipelines with automated testing reduce change failure rate to 5-15% versus 40-60% for manual deployments.
When
Complex delivery pipelines needing visual flow tracking and fan-in/fan-out. Avoid complex pipeline orchestration for repos with fewer than 5 contributors — a pre-commit hook + GitHub Actions suffices.
Skip self-hosted runners unless you need GPU or VPN access.
How
# GoCD pipeline config (XML)
<pipeline name="build-and-deploy">
<materials>
<git url="https://github.com/myorg/app.git" branch="main" />
</materials>
<stage name="build">
<jobs>
<job name="compile">
<tasks>
<exec command="npm" args="ci" />
<exec command="npm" args="run build" />
</tasks>
<artifacts>
<artifact src="dist/**" />
</artifacts>
</job>
</jobs>
</stage>
<stage name="deploy">
<jobs>
<job name="deploy-prod">
<tasks>
<exec command="kubectl" args="apply -f k8s/" />
</tasks>
</job>
</jobs>
</stage>
</pipeline>
4. Verify deployment — curl -I https://your-app.example.com
5. Monitor logs — check for errors in first 5 minutes
6. Rollback if needed — revert to previous version
Example
# GoCD server via Docker
docker run -d --name gocd-server \
-p 8153:8153 -p 8154:8154 \
-v gocd-data:/godata \
gocd/gocd-server:v24.1
Common Problems
- ⚠Config repo not updating — check material polling
- ⚠Agent idle — ensure elastic agents plugin configured
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use config repos — pipeline definitions in Git
- ✓Use elastic agents — scale agents with build demand
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit