CI/CD & build tooling
Jenkinsfile
A Jenkinsfile defines a pipeline as code, stored and reviewed alongside the application. Interviews typically ask you to write or critique one on a whiteboard: build → test → scan → push → deploy to staging → approval → production, with parallel tests, credentials handled safely, and clean failure handling. This topic is a complete reference to declarative syntax plus the patterns that make pipelines fast, safe and maintainable.
After this topic you can
- Write declarative Jenkinsfiles with stages, parallelism and post steps
- Handle credentials, approvals and environments
- Structure pipelines with shared libraries
Lessons
-
1Declarative vs scripted pipelines
- Two syntaxes, one engine
- Where a Jenkinsfile comes from
-
2The declarative skeleton, directive by directive
- options
- parameters
- environment
- triggers
- tools
- post conditions
-
3Agents and workspaces
- Agent variants
- agent none + per-stage agents
- Workspaces
-
4Conditions, parallelism and resilience
- when
- parallel
- matrix
- Resilience steps
-
5Credentials, environment and parameters in practice
- Binding credentials
- Setting and passing values between stages
- withEnv
-
6Approvals and promotion
- The input directive (preferred) vs input step
- Promotion in a GitOps world
- 7Reports, artifacts and notifications
- 8A complete production Jenkinsfile
-
9Tooling, debugging and common errors
- Tools that save time
- Common errors
- Speeding up a slow pipeline
-
10Interview questions and model answers
- "Write a pipeline for build, test, staging deploy, approval and production deploy."
- "Declarative or scripted?"
- "How do you pass a value computed in one stage to a later stage?"
- "Why put input outside an agent?"
- "How do you stop two builds deploying to staging at the same time?"
- "A security scan finds critical CVEs. How does the pipeline prevent a deploy?"
- "What's the difference between failure, unstable and aborted in post?"