Jenkins From Beginning

Rasalingam Ragul
5 min readApr 2, 2023

--

In this article I’ll share my knowledge about open source automation server Jenkins. Before dive in to Jenkins we have to understand CI/CD.

What is CI/CD?

CI and CD stand for continuous integration and continuous delivery/continuous deployment. In very simple terms, CI is a modern software development practice in which incremental code changes are made frequently and reliably. Automated build-and-test steps triggered by CI ensure that code changes being merged into the repository are reliable. The code is then delivered quickly and seamlessly as a part of the CD process. In the software world, the CI/CD pipeline refers to the automation that enables incremental code changes from developers’ desktops to be delivered quickly and reliably to production.

What is Jenkins?

Jenkins is an open source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.

How to install Jenkins?

There are multiple ways to install Jenkins in my case i am using Linux OS and i install Jenkins as Linux package you can refer below link

https://www.baeldung.com/linux/jenkins-install-run

if your using different OS use this link https://www.wikihow.com/Install-Jenkins

Basic configuration of Jenkins

After installing Jenkins, there are a few basic configuration steps you should follow to get started with the tool:

  1. Create an administrator account: During the initial setup, you will be prompted to create an administrator account for Jenkins. This account will have full access to all features of Jenkins and should be used for managing and configuring the tool.
  2. Configure plugins: Jenkins provides a wide range of plugins that can be used to extend the functionality of the tool. To configure plugins, navigate to the “Manage Jenkins” page and click “Manage Plugins.” From here, you can browse and install new plugins, as well as configure existing ones.
  3. Create a job: A job in Jenkins is a specific task that can be executed as part of a software development project, such as compiling code, running tests, or deploying an application. To create a job, navigate to the Jenkins home page and click “New Item.” From here, you can choose the type of job you want to create, configure its settings, and define the steps it should perform.
  4. Set up source code management: To use Jenkins for software development, you will need to configure source code management (SCM) tools, such as Git or Subversion. To set up SCM, navigate to the “Configure” page for a job, and select the appropriate SCM tool from the “Source Code Management” section.
  5. Configure build triggers: Jenkins can be configured to automatically trigger builds based on specific events, such as code changes or scheduled intervals. To configure build triggers, navigate to the “Configure” page for a job, and select the appropriate trigger from the “Build Triggers” section.
  6. Configure email notifications: Jenkins can be configured to send email notifications when builds fail or succeed. To set up email notifications, navigate to the “Configure System” page and enter the SMTP server information for your email provider.

By following these basic configuration steps, you can begin using Jenkins to automate your software development process and improve the speed and efficiency of your projects.

Create First Jenkins Job

For creating Jenkins job first you need login Jenkins with your account. For this example I’m use simple Java project.

  1. Click + New Item as below

2. Select Pipeline project then type your project name in the input box and click OK.

3. Add Pipeline script

pipeline {
agent any
tools{
maven 'M3'
}
stages{
stage('Build Maven'){
steps{
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/rragul/java-jenkins']]])
sh 'mvn clean install'
}
}
}
}

In the above script i add my GitHub repository if you want to add your repository you can change the url as your repository link and you need to change your branch name as name. Then click save button

Now you navigate to new page like this

In hear we need to click Build Now button but before that we need to configure Maven in Global Tool Configuration for that first click Dashboard on the top left side now you get page like this

Now click the Manage Jenkins and click Global Tool Configuration

Now scroll down and find Maven after click the drop down below that then click Add Maven button and type name as ‘M3’ and check the Install automatically check box and click save button

now all the required steps are done no more wait lets click the My Views on the Dashboard then select first-job

This is the last step click the Build Now button

now your build starts after few seconds your build was finish successful and your page look like this

you can check the console output by clicking the marked icon.

This the simple example of Jenkins pipeline job with basic java project. In this article i share my knowledge about one of the CI/CD tools Jenkins but there are lot of tools available. Jenkins has advantages and disadvantages over them you can find them using below link

--

--