Introduction to Jenkins
Jenkins is an open-source automation server that enables developers around the world to reliably build, test, and deploy their software. It is the backbone of DevOps CI/CD (Continuous Integration/Continuous Delivery) workflows, automating repetitive tasks in the software release lifecycle.
Understanding Continuous Integration (CI)
Continuous Integration is the practice of integrating code changes from multiple developers into a single shared branch frequently. Jenkins monitors git repositories for new commits, automatically triggers code compilation, runs unit tests, and alerts the development team if any tests fail, maintaining high code quality.
Jenkins Pipelines and Code Delivery
Jenkins utilizes 'Pipelines' to orchestrate deployment steps. Using a text file called a Jenkinsfile committed to the project repository, developers define distinct build stages (e.g. Test, Build Container, Deploy to Cloud). This Infrastructure-as-Code approach ensures release pipelines are repeatable and transparent.
Declarative Jenkins Pipeline Configuration (Jenkinsfile)
pipeline {
agent any
stages {
stage('Repository Checkout') {
steps {
git branch: 'main', url: 'https://github.com/cacts/sample-api.git'
}
}
stage('Unit Testing') {
steps {
sh 'npm run test'
}
}
stage('Containerize & Deploy') {
steps {
sh 'docker build -t cacts-api:latest .'
sh 'docker run -d -p 8080:8080 cacts-api:latest'
}
}
}
}
Official Documentation
Access official code repositories and developer documentation.