A Brief History of Jenkins
Jenkins, the beloved but sometimes infuriating CI/CD tool, was born out of necessity.
Back in 2004, Kohsuke Kawaguchi, a Sun Microsystems engineer, was tired of breaking builds and getting yelled at by his team.
So, like any good developer, he built a tool to automate the pain away.
This tool was originally called Hudson, but after some corporate drama with Oracle, it was forked and renamed Jenkins in 2011.
Since then, it has become the go-to tool for continuous integration and deployment.
(Fun note- Hudson was the version I learned initially :) - Yes.. I am old )
What is Continuous Integration and Continuous Deployment (CI/CD)?
Continuous Integration (CI) is like having a really strict but fair coding buddy who immediately runs tests whenever you push code.
If your code fails, it tells you instantly, saving you from merging a disaster into production.
Continuous Deployment (CD) takes it a step further and says, “Hey, your code passed?
Let’s deploy it to production automatically.” This ensures that software is always in a deployable state, with minimal human intervention.
In short: CI catches problems early, and CD ensures you’re always ready to ship.
Setting Up a Sample Microservice
Before Jenkins can do anything useful, we need something to build and test.
Let’s create a simple C# microservice that exposes a REST API to divide two numbers. If you try to divide by zero, it will yell at you—because math.
C# Microservice Code
|
|
Unit Tests for the Microservice
|
|
Running Unit Tests from the Command Line
|
|
If all goes well, you’ll see some green checkmarks. If not, well, time to debug.
Configuring Jenkins to Monitor Git and Build Code
- Install Jenkins and necessary plugins (
Git
,Pipeline
,Docker Pipeline
). - Set up a new Freestyle Project or a Pipeline Project.
- Link it to your Git repository.
- Configure Jenkins to trigger a build when new code is pushed.
Example Jenkinsfile for CI/CD
|
|
What Happens if You Push Code Before the First Build Completes?
Chaos. Jenkins will either queue the new build or cancel the old one, depending on how it’s configured. Either way, you’ll probably get an email from your team.
Where Does Jenkins Put Built Files?
Jenkins stores built artifacts in /var/lib/jenkins/workspace/<job-name>/
by default. You can configure it to store them elsewhere.
Setting Up Failure Notifications
To notify a human when the build fails, configure Email Notifications or Slack Webhooks.
|
|
Testing the API After Deployment
Create a simple test script:
|
|
Make it executable:
|
|
Deploying to Docker with Jenkins
Modify the Jenkins pipeline to build and run the Docker container, then execute test-api.sh
.
|
|
Cleaning Up After Docker Tests
|
|
Retaining Files in Jenkins
Configure Build Artifacts in Jenkins to retain compiled files:
- Keep artifacts for a certain number of builds.
- Use “Discard old builds” to prevent disk bloat.
Competing CI/CD Tools
Jenkins isn’t the only player. Here are some alternatives:
- GitHub Actions – Simple, integrated into GitHub.
- GitLab CI/CD – Built-in CI for GitLab.
- CircleCI – Cloud-based and fast.
- Travis CI – Once great, now fading.
- Azure DevOps – Microsoft’s answer to Jenkins.
- TeamCity – Enterprise-grade CI/CD.