Introduction to Jenkins
What is Jenkins?
Jenkins is an open-source automation server written in Java. It automates the repetitive tasks of the software development lifecycle:
- Build: Compiling the code
- Test: Running automated tests
- Analysis: Code quality (SonarQube, linting)
- Deployment: Releasing to production
CI/CD with Jenkins
Continuous Integration (CI)
Continuous Deployment (CD)
Architecture
Main components
Controller (Master)
The Jenkins controller:
- Manages the web interface
- Schedules builds
- Stores the configuration
- Distributes tasks to the agents
Agents (Slaves)
Agents run the builds:
- Can be on different platforms
- Connect to the controller via JNLP or SSH
- Can be static or dynamic (cloud)
Key concepts
Job / Project
A job is an automated task. Job types:
| Type | Description | Usage |
|---|---|---|
| Freestyle | Configuration via UI | Simple jobs |
| Pipeline | Groovy code (Jenkinsfile) | Complex CI/CD |
| Multibranch | One pipeline per branch | Git projects |
| Folder | Job organization | Structure |
Build
A build is an execution of a job. Each build has:
- A unique number (#1, #2, ...)
- A status (Success, Failure, Unstable, Aborted)
- Logs
- Artifacts (optional)
Workspace
The workspace is the working directory where the code is cloned and the build runs.
/var/jenkins_home/workspace/
├── my-project/
│ ├── src/
│ ├── pom.xml
│ └── target/
└── another-project/
Artifact
An artifact is a file produced by a build:
- Java JAR/WAR
- Compiled binaries
- Docker images
- Test reports
Jenkins vs other CI/CD tools
| Aspect | Jenkins | GitHub Actions | GitLab CI | CircleCI |
|---|---|---|---|---|
| Hosting | Self-hosted | Cloud | Cloud/Self | Cloud |
| Configuration | Jenkinsfile/UI | YAML | YAML | YAML |
| Plugins | 1800+ | Actions | Built-in | Orbs |
| Cost | Free | Freemium | Freemium | Paid |
| Learning curve | Medium | Easy | Easy | Easy |
| Flexibility | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ |
When to choose Jenkins?
- On-premise infrastructure required
- Need for extreme customization
- Specific (legacy) integrations
- Full control over the environment
Typical workflow
Terminology
| Term | Description |
|---|---|
| Controller | Main Jenkins server |
| Agent | Build execution node |
| Job | Automated task |
| Build | Execution of a job |
| Pipeline | CI/CD workflow as code |
| Stage | Step of a pipeline |
| Step | Action within a stage |
| Workspace | Working directory |
| Artifact | Produced file |
| Plugin | Jenkins extension |
Benefits of Jenkins
1. Open Source and free
# Pas de licence à payer
# Communauté active
# Documentation abondante
2. Extensibility
More than 1800 plugins for:
- SCM integrations (Git, SVN, Mercurial)
- Build tools (Maven, Gradle, npm)
- Cloud (AWS, Azure, GCP)
- Containers (Docker, Kubernetes)
- Notifications (Slack, Email, Teams)
- Quality (SonarQube, Checkmarx)
3. Pipeline as Code
// Jenkinsfile versionné avec le code
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('Deploy') {
steps {
sh 'kubectl apply -f k8s/'
}
}
}
}
4. Scalability
- Distributed master/agents architecture
- Dynamic agents (Kubernetes, Docker, EC2)
- Build parallelization
Limitations of Jenkins
| Limitation | Mitigation |
|---|---|
| Dated interface | Blue Ocean plugin |
| Complex configuration | Jenkins Configuration as Code |
| Server maintenance | Jenkins on Kubernetes |
| Sometimes unstable plugins | LTS versions |
| Groovy learning curve | Shared Libraries |
Summary
- Jenkins is an open-source CI/CD automation server
- Master/agent architecture for scalability
- Pipeline as Code with Jenkinsfile
- Rich plugin ecosystem
- Ideal for on-premise environments