One of the most significant benefits of Jenkins is its extensive plugin ecosystem. The Jenkins community has developed hundreds of plugins, making it adaptable to a wide variety of build, test, and deployment technologies. Whether you need to integrate with Git, run an MSTest suite, or publish an Apache Maven site, there’s a good chance that Jenkins has a plugin that does exactly what you need. Please keep security of your system in mind before trying or installing an unknown or new plugin.
Jenkins supports customizable workflows. With the Jenkins Pipeline plugin, you can describe your entire CI/CD pipeline in code. This “Pipeline as Code” approach allows you to version control your delivery pipeline, making your CI/CD process replicable and more robust.
Jenkins comes with rich documentation and resources. Whether you’re a beginner or an advanced Jenkins user, the Jenkins community has produced a wealth of documentation, tutorials, and resources to help you get started and to solve any issues you might encounter.
Another benefit that Jenkins offers is parallel execution. Jenkins allows you to run multiple jobs concurrently, thereby speeding up the build and delivery process. This is particularly useful if you have a large, complex codebase or if you’re working with a distributed team.
sudo apt update
sudo apt install openjdk-17-jre
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null sudo apt-get update sudo apt-get install jenkins sudo systemctl start jenkins.service sudo systemctl status jenkins
After installing Jenkins, the next step is to set it up. Open your browser and navigate to http://localhost:8080. You should see the Jenkins dashboard. The setup wizard will guide you through the initial configuration.
The first thing you’ll see is the ‘Unlock Jenkins’ screen. Jenkins generates an initial password that you’ll need to unlock it. You’ll find this password in a file in your home directory. You can display the password in your terminal by running:
“sudo cat /var/lib/jenkins/secrets/initialAdminPassword”
Copy the password and paste it into the ‘Administrator password’ field on the ‘Unlock Jenkins’ screen, then click ‘Continue’. On the next screen, you’ll be asked to customize Jenkins by installing suggested plugins or selecting specific plugins. For this tutorial, choose the ‘Install suggested plugins’ option.
Now that Jenkins is set up, it’s time to create a new Jenkins job. A Jenkins job is a series of operations that Jenkins will execute. These operations can include building a software project, running tests, deploying code, and more.
To create a new job, navigate to the Jenkins dashboard and click on ‘New Item’ at the top left. You’ll be prompted to enter a name for your job and choose the type of job to create. For this tutorial, enter ‘My First Job’ as the name and choose ‘Freestyle project’, then click ‘OK’ to create the job.
The next step is to configure the build trigger. The build trigger defines when Jenkins should run your job. You can configure Jenkins to run your job at specific times, or when certain events occur.
In your job configuration page, scroll down to the ‘Build Triggers’ section. For this tutorial, we’ll configure Jenkins to build our job periodically. Check the ‘Build periodically’ box and enter ‘H * * * *’ in the ‘Schedule’ field. This configuration tells Jenkins to run the job every hour.
After configuring the build trigger, it’s time to add build steps. Build steps are the tasks that Jenkins will execute when it runs your job.
In your job configuration page, scroll down to the ‘Build’ section and click on ‘Add build step’. You’ll see a list of build step types you can add. For this tutorial, choose ‘Execute shell’ and enter the following command in the ‘Command’ field:
“echo “Hello, World!””
This command simply prints the string “Hello, World!” to the console. It’s a simple example, but in real-world projects, your build steps could involve compiling code, running tests, deploying code, and more.
Finally, after adding the build steps, click ‘Save’ at the bottom of the page to save your job configuration. You’ll be redirected to your job’s main page.
To run your job, click ‘Build Now’ on the left. Jenkins will run your job and display the result in the ‘Build History’ section. If everything is set up correctly, you should see a blue or green ball indicating a successful build.
Congratulations! You’ve just created your first CI/CD pipeline with Jenkins.
This tutorial was just a basic introduction to Jenkins and CI/CD pipelines. There’s a lot more you can do with Jenkins, like setting up pipelines for multi-branch projects, integrating with other tools, and customizing your build steps with scripts.