Jenkins
The veteran automation server — pipelines as code with Jenkinsfiles and agents.
Jenkins is a long-established, self-hosted automation server. Its strength is a massive plugin ecosystem and flexibility; its cost is that you run and maintain the controller and agents.
Modern Jenkins uses Pipeline as code — a Jenkinsfile (declarative syntax) checked into the repo. A controller schedules work onto agents (nodes/ executors). You define stages and steps, store secrets in the credentials store, and trigger builds by SCM webhooks or polling.
pipeline {
agent any
stages {
stage('Build') { steps { sh 'npm ci' } }
stage('Test') { steps { sh 'npm test' } }
stage('Deploy') {
when { branch 'main' }
steps {
withCredentials([string(credentialsId: 'deploy-token', variable: 'TOKEN')]) {
sh './deploy.sh'
}
}
}
}
post { failure { echo 'Build failed' } }
} - Write a declarative Jenkinsfile with build, test, and deploy stages.
- Restrict the deploy stage to the main branch with
when. - Use
withCredentialsto inject a secret without printing it. - Compare Jenkins to a hosted CI service in two sentences.
Cheat Sheet▾
| Concept | Detail |
|---|---|
| Jenkinsfile | Pipeline as code (Groovy) |
| Controller | Schedules builds |
| Agent / executor | Runs the work |
| stages / steps | Pipeline structure |
| Plugins | Extend functionality |
| Credentials store | Manage secrets |
when | Conditional stage |
Common Interview Questions▾
What is a Jenkinsfile?
A pipeline definition as code, checked into the repo, describing stages and steps in declarative (or scripted) syntax — so the build process is versioned alongside the code.
What's a trade-off of Jenkins versus hosted CI?
Jenkins offers maximum flexibility and a huge plugin ecosystem but requires you to host, secure, and maintain the controller and agents — work that managed CI services handle for you.