Jenkins Basics
Introduction to Jenkins
Jenkins is a powerful open-source automation server designed for continuous integration and continuous deployment (CI/CD) workflows. As a critical DevOps automation tool, Jenkins enables software development teams to streamline and automate various stages of software delivery.
Core Concepts and Architecture
Jenkins operates on a master-slave architecture that supports distributed build environments. Key components include:
graph TD
A[Jenkins Master] --> B[Build Nodes]
A --> C[Plugins]
A --> D[Job Configurations]
Component |
Description |
Master |
Central control unit managing jobs and nodes |
Nodes |
Execution environments for build tasks |
Plugins |
Extend Jenkins functionality |
Installation on Ubuntu 22.04
## Update system packages
sudo apt update
## Install Java Runtime Environment
sudo apt install openjdk-11-jre-headless
## Import Jenkins repository key
wget -q -O - | sudo apt-key add -
## Add Jenkins repository
sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'
## Install Jenkins
sudo apt update
sudo apt install jenkins
Basic Configuration and First Job
After installation, Jenkins provides a web interface for configuration and job management. The initial setup involves:
- Accessing web interface at
- Retrieving initial admin password
- Installing recommended plugins
- Creating first build job
Sample Jenkins Pipeline Script
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('Deploy') {
steps {
sh 'docker build -t myapp .'
}
}
}
}
This script demonstrates a typical CI/CD workflow with build, test, and deployment stages.