Unit III Continuous Integration Using Jenkins
Unit III Continuous Integration Using Jenkins
Unit III Continuous Integration Using Jenkins
Install & Configure Jenkins, Jenkins Architecture Overview, Creating a Jenkins Job, Configuring a Jenkins job,
Introduction to Plugins, Adding Plugins to Jenkins, Commonly used plugins (Git Plugin, Parameter Plugin, HTML
Publisher, Copy Artifact and Extended choice parameters). Configuring Jenkins to work with java, Git and Maven,
Creating a Jenkins Build and Jenkins workspace.
UNIT - III
Continues Integration - Continuous Integration is a software development method where team members
In Continuous Integration after a code commit, the software is built and tested immediately.
In a large project with many developers, commits are made many times during a day. With each commit code is
built and tested. If the test is passed, build is tested for deployment. If the deployment is a success, the code is
pushed to Production. This commit, build, test, and deploy is a continuous process, and hence the name
continuous integration/deployment.
UNIT - III
CI Workflow:
UNIT - III
These three processes are responsible for taking the software from its first phase to the final phase.
UNIT - III
CI/CD Tools
UNIT - III
Code Compilation:
• Compilation is the process the computer takes to convert a high-level programming language code into a
machine language that the computer able to understand. It ensures a code compiler on every target platform.
Continuous Integration:
DB integration:
• Ensure DB and code in sync
• Automated creation of DB and test data.
Code Inspection:
• Ensures a healthy codebase
• Identifies problems early and applies best practices
Automated Deployment:
• Allows you to release product anytime
• Continually demo-able state and it is works on any machine
Document generation:
• Ensure documentation is current
• Produces build reports and metrics
UNIT - III
1. Reduces Risk
The frequent testing and deployment of code reduce the project's risk level, as now the code defects and bugs can be detected earlier. This states that these
bugs and errors can be easily fixed and take less time, making the overall process cheaper. The general working speeds up the feedback mechanism that makes
the communication smoother and effective.
2. Better Communication
The Continuous Integration process collaborates with the Continuous Delivery workflow that makes code sharing easy and regularized. This makes the
process more transparent and collaborative among team members. In the long term, this makes the communication speed more efficient and makes sure that
everyone in the organization is on the same page.
Continuous Integration provides features like Code review and Code quality detection, making the identification of errors easy. If the code does not match
the standard level or a mistake, it will be alerted with emails . Code review helps the developers to improve their programming skills continually.
The time between the application development, integration, testing, and deployment is considerably reduced. When this time is reduced, it, in turn, reduces
the waiting time that may occur in the middle. CI makes sure that all these processes continue to happen no matter what.
UNIT - III
What is Jenkins?
• Jenkins is an open-source automation tool written in Java with plugins built for continuous integration. Jenkins is
used to build and test your software projects continuously making it easier for developers to integrate changes
to the project, and making it easier for users to obtain a fresh build.
• It also allows you to continuously deliver your software by integrating with a large number of testing and
deployment technologies.
• With Jenkins, organizations can accelerate the software development process through automation. Jenkins
integrates development life-cycle processes of all kinds, including build, document, test, package, stage, deploy,
static analysis, and much more.
• Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various
DevOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool. For
UNIT - III
Jenkins Architecture :
• First, a developer commits the code to the source code repository. Meanwhile, the Jenkins server checks the repository at regular intervals for changes.
• Soon after a commit occurs, the Jenkins server detects the changes that have occurred in the source code repository. Jenkins will pull those changes and will start
preparing a new build.
• If built is successful, then Jenkins deploys the built in the test server.
• After testing, Jenkins generates a feedback and then notifies the developers about the build and test results.
UNIT - III
Jenkins Distributed Architecture
Jenkins uses a Master-Slave architecture to manage distributed builds. In this architecture, Master and Slave communicate through TCP/IP
protocol.
Options Description
Freestyle Project in Jenkins is an improvised or unrestricted build job or task with multiple operations.
Freestyle Project
Operations can be a build, pipeline run, or any script run.
Maven project is selected for managing as well as building the projects which contain POM files. Jenkins
Maven Project
will automatically pick the POM files, make configurations, and run our build.
Pipeline demonstrates long-running activities that contain multiple build agents. It is suitable for
Pipeline
running pipelines that cannot run through normal freestyle type jobs.
This option is suitable in those conditions where different configurations like testing on multiple
Multi-configuration Project
environments, platform-specific builds are required.
GitHub Organization This option scans the User’s GitHub account for all repositories matching some defined markers.
UNIT - III
1. Access Jenkins:
Click on the "New Item" or "Create a new job" link, usually located on the left-hand side of the dashboard.
Select the type of job you want to create. Jenkins supports various job types, including Freestyle projects, Pipeline
projects (using Jenkinsfile), and more. Choose the one that suits your requirements.
Give your job a descriptive name that reflects its purpose. This name should be unique within your Jenkins instance.
UNIT - III
Depending on the job type you selected, you will have various settings to configure. Here are some common configurations:
• Source Code Management (SCM): Specify the source code repository (e.g., Git, Subversion) and provide repository
details.
• Build Triggers: Define when the job should run (e.g., on code commit, scheduled time).
• Build Environment: Configure build environment settings, such as build tools, build parameters, and environmental
variables.
• Build Steps: Specify the build steps or shell commands to execute. This is where you define what the job should do,
such as compiling code, running tests, or deploying applications.
• Post-Build Actions: Set actions to perform after the build, such as archiving artifacts, sending notifications, or
triggering downstream jobs.
UNIT - III
• Enter the new project's name in the Enter an item name field and select the Freestyle project type. Click OK to continue.
UNIT - III
• Under the General tab, add a project description in the Description field. (Job Name)
UNIT - III
• Enter the commands you want to execute in the Command field. For this tutorial, we are using a simple set of commands
that display the current version of Java and Jenkins working directory.
• Click the Save button to save changes to the project.
UNIT - III
• Click the Build Now link on the left-hand side of the new project page.
UNIT - III
• Click the Console Output link on the left-hand side to display the output for the commands you entered.
UNIT - III
• The console output indicates that Jenkins is successfully executing the commands, displaying the current version of Java
and Jenkins working directory.
UNIT - III
After you have provided all the project & repo details, the next part is to build the code
UNIT - III
Console Output:
‘HelloWorld’ program on GitHub. Jenkin pulled up the source code from the remote repository and continuously built it.
UNIT - III
Jenkin Plugins:
• Plugins are the primary means of enhancing the functionality of a Jenkins environment to suit organization- or user-
specific needs.
• 1,800+ plugins is available on Jenkins that equips it with additional features or functionalities you require in the software
development life cycle (SDLC).
How to Get a Plugin for Jenkins?
• Jenkins plugin download involves a few steps and is pretty easy to follow through. Here is how to install plugin in
Jenkins,
• First, log in to Jenkins and open the Jenkins Dashboard.
• Now, on the left menu bar, click on the Manage Jenkins option.
• Then, under the Manage Jenkins window, select the Manage Plugins button.
• Next, click on the Available tab above and search for the plugin you are looking for in the search box beside the Filter
option.
• Now, from the search result, select the plugin and click on the Install without restart button below.
• Finally, select the Go back to the top page link once the installation is done.
Jenkins offers a vast ecosystem of plugins that extend its functionality and allow for integration with various tools and
technologies. Here is a list of some popular and widely used Jenkins plugins:
UNIT - III
Jenkins offers a vast ecosystem of plugins that extend its functionality and allow for integration with various tools and
technologies.
Pipeline Plugin: Enables the creation and management of continuous delivery pipelines in Jenkins.
GitHub Plugin: Provides integration with GitHub repositories, enabling automatic builds upon code commits.
Docker Plugin: Allows Jenkins to build, publish, and run Docker containers.
Maven Plugin: Integrates Jenkins with Apache Maven for building Java projects.
Blue Ocean Plugin: Offers a modern and user-friendly interface for Jenkins.
Credentials Plugin: Manages and securely stores credentials used in Jenkins jobs.
Ansible Plugin: Integrates Jenkins with Ansible for configuration management and automation.
Selenium Plugin: Allows for running Selenium tests as part of Jenkins jobs.
Amazon EC2 Plugin: Provides dynamic build agents on Amazon EC2 instances.
JIRA Plugin: Enables integration with Atlassian JIRA for issue tracking.
Artifactory Plugin: Enables integration with JFrog Artifactory for artifact management.
UNIT - III
Git Plugin
• Git is one of the most installed Jenkins add-ons available on its repository. It allows you to integrate Jenkins with GitHub and transfer GitHub repository data to
the Jenkins machine easily. The key features of this plugin are listed below:
• The Git plugin performs fundamental Git operations like polling, branching, merging, fetching, tagging, listing, and pushing repositories.
• It helps you to schedule your builds and automatically triggers each build after each commit.
• The Git plugin adds the functionality and flexibility any DevOps engineer will require for better project delivery.
• This plugin allows you to access GitHub as a Source Code Management (SCM) system.
• Link: https://plugins.jenkins.io/git/
Kubernetes Plugin
• Kubernetes is another widely used plugin in Jenkins. It allows you to run all the dynamic agents in a Kubernetes cluster. This plugin creates a Kubernetes Pod
for each agent getting started and stopped once the build is finished. You can find a plethora of advanced features of this plugin, such as:
• With this plugin, you can automatically scale the running process of Jenkins agents in the Kubernetes environment.
• It creates individual Kubernetes Pods for each agent on the Docker image.
• The Kubernetes plugin also terminates the Kubernetes Pods automatically once you finish the build.
• Link: https://plugins.jenkins.io/kubernetes/
UNIT - III
Jira Plugin
• The Jira plugin integrates Jenkins with Atlassian Jira Software. You can work with both the Cloud and Server versions with this Jenkins plugin. But you need
to use a Jira service account instead of a Jira personal account to install this plugin. This plugin comes with the below features:
• The Jira plugin enables you to get better visibility into the development pipeline.
• You can display the builds inside Jira with this plugin.
• It also automatically sends development and build-related data from Jenkins to Jira.
• Above all, this Jira plugin can help you track Jira issues inside Jenkins.
• Link: https://plugins.jenkins.io/jira/
Docker Plugin
• The Jenkins cloud plugin for Docker is the most effective solution for DevOps engineers to integrate Jenkins with Docker. It allows you to dynamically
provision the Docker containers and run those as Jenkins agent nodes. Its notable features are:
• The Docker plugin enables you to create Docker containers and automatically run builds on them.
• It is a cloud implementation, so you need to add Docker as a new cloud type on Jenkins.
• Docker Swarm Standalone is available to run multiple docker hosts as Jenkins nodes.
UNIT - III
• Jenkins has native Maven support, although you may need deeper integration if you use it. This Jenkins plugin is available independently and offers greater
Jenkins integration for Apache Maven projects. Some of the more sophisticated features of the plugin are:
• Disseminate and take in snapshots and have them instantly activate other processes.
• The automatic post-build binary deployment when the project passes all the necessary checks.
• Link: https://plugins.jenkins.io/maven-plugin/
• According to the Blue Ocean functionalities, Jenkins' interface was recently updated. Blue Ocean, designed in tandem with Jenkins Pipeline and compatible
with the Freestyle jobs, provides you with several useful features, such as:
• Offers an easy understanding of the current phase of a software development cycle thanks to its sophisticated visualizations of CD pipelines.
• The Blue Ocean UI highlights exactly which pipeline stage needs your attention for better exception handling and production.
• It includes built-in features like branching and pulling requests, making it easier for developers to work on codes with others and save development time.
• Link: https://plugins.jenkins.io/blueocean/
UNIT - III
• Amazon EC2 plugin lets Jenkins start up new EC2 or Eucalyptus agents on demand and shut them down when they are no longer needed.
• If your build cluster becomes overcrowded, this plugin will launch EC2 instances and configure those as Jenkins agents. Unused EC2 instances will be stopped when the load
decreases. Some of the most useful features of Amazon EC2 plugins include the following:
• Using the EC2 plugin, you can meet high build and test demands with a small in-house cluster.
• Comes with the Amazon IAM feature that lets you create a separate account for Jenkins.
• Offers strong strategies to ensure that the instances you have connected to are the expected ones. This keeps your builds safe from the man-in-the-middle attack.
• Link: https://plugins.jenkins.io/ec2/
Pipeline Plugin
• The Jenkins 2.0 version came with the Jenkins Pipeline plugin. It's an extremely useful tool for DevOps teams. A pipeline is, in fact, a collection of plugins that are used to make
pipelines for continuous integration.
• The plugin allows you to script the build pipeline available for one or multiple build jobs present in a single workflow. This helps the team to check all the upstream and
downstream connected jobs in a single view. Thus, it becomes much easier to define manual triggers for jobs that need further intervention before execution. Some of the best
features that can define the Pipeline Plugin are
• It helps teams to easily monitor which parts of the build pipeline are running and which are still in the queue.
• With the Pipeline plugin, you can check historical changes, audit and perform code reviews.
UNIT - III
SonarQuobe
• SonarQuobe is an open-source tool used for continuous code quality inspection. The Jenkins monitoring plugin allows you to integrate SonarQube into
Jenkins so that you can easily analyze a code while running a Jenkins job that comes with SonarQuobe execution. Developers can use this plugin to
identify vulnerabilities, bugs, and the possibility of duplication while building codes on the Jenkins automation server. Some of the best features of this
plugin include the following:
• It's easy to integrate and manage on Jenkins.
• Offers necessary security feedback at the time of code review.
• Allows navigating any problem from the vulnerability source to the code location quickly.
• Link: https://plugins.jenkins.io/sonar/#documentation
Metrics Plugin
• Metrics is a Java library that offers a toolkit to measure the performance metrics of the critical components in your production environment. The
Metrics Jenkins plugin exhibits the same API of Metrics as all the other Jenkins plugins. It offers additional metrics through columns in Jenkins' list view.
• Metrics are available as a Dropwizard Metrics API, which offers health check contracts. It comes with a simple return message that shows the
PASS/FAIL status with an optional message. The key features of the Metrics plugin on Jenkins include:
• A MetricsRegistry class container that saves all your Jenkins applications metrics.
• Offers Histograms to measure all the statistical distribution values in the data stream.
• The metrics-healthchecks module lets you centralize your services' health checks.
• Link: https://plugins.jenkins.io/metrics/
UNIT - III
Git Plugins
• GitHub is a web-based repository of code which plays a major role in DevOps. It provides a common platform for multiple developers
working on the same code/project to upload and retrieve updated code, thereby facilitating continuous integration.
• Jenkins needs to have GitHub plugin installed to be able to pull code from the GitHub repository.
• You need not install a GitHub plugin if you have already installed the Git plugin in response to the prompt during the Jenkins’ installation
setup. But if not, here is how you install GitHub plugins in Jenkins and pull code from a GitHub repository.
How to Install Git Plugin in Jenkins
Following is a step by step process on how to Install Git plugin in Jenkins:
• Step 1: Open your dashboard.
Click on the Manage Jenkins button on your Jenkins dashboard:
UNIT - III
Step 2: Find plugins option.
Click on Manage Plugins:
UNIT - III
Step 3: In the Plugins Page,
1. Select the GIT Plugin
2. Click on Install without restart. The plugin will take a few moments to finish downloading depending on your internet connection,
and will be installed automatically.
3. You can also select the option Download now and Install after restart button. In which plugin is installed after restart
4. You will be shown a “No updates available” message if you already have the Git plugin installed.
UNIT - III
Step 2) Enter the item name, select job type and click OK. We shall create a Freestyle project as an example.
UNIT - III
Step 3) Once you click OK, the page will be redirected to its project form. Here you will need to enter the project information:
UNIT - III
Step 4) You will see a Git option under Source Code Management if your Git plugin has been installed in Jenkins:
NOTE: If the Git option does not appear, try re-installing the plugins, followed by a restart and a re-login into your Jenkins
dashboard. You will now be able to see the Git option as mentioned above.
UNIT - III
Step 5) Enter the Git repository URL to pull the code from GitHub.
UNIT - III
Step 6) You might get an error message the first time you enter the repository URL.
For example:
This happens if you do not have Git installed in your local machine. To install Git in your local machine
UNIT - III
Once you have everything in place, try adding the Git URL into Jenkins. You will not see any error messages for Jenkins Git
integration:
UNIT - III
Source Code Management: The Git Plugin allows you to specify the Git repository URL, credentials (if needed), and branch to monitor. Jenkins can automatically
poll the repository for changes and trigger builds when code changes are detected.
Build Triggers: You can set up different triggers for your Jenkins jobs, such as building on a regular schedule, when changes are pushed to the Git repository, or
manually by a user.
Build Actions: You can define build actions that Jenkins should perform when building code from a Git repository. This can include compiling code, running tests,
generating artifacts, and more.
Multiple Repositories: The plugin supports multiple Git repositories for a single Jenkins job. This is useful when your project depends on code from multiple
sources.
Change Logs: Jenkins can generate change logs that detail what code changes were included in a specific build. This is valuable for tracking the history of your builds
and releases.
UNIT - III
Here are some key features and functions of the Git Plugin for Jenkins:
Source Code Management: The Git Plugin allows you to specify the Git repository URL, credentials (if needed), and branch to monitor. Jenkins can automatically
poll the repository for changes and trigger builds when code changes are detected.
Build Triggers: You can set up different triggers for your Jenkins jobs, such as building on a regular schedule, when changes are pushed to the Git repository, or
manually by a user.
Build Actions: You can define build actions that Jenkins should perform when building code from a Git repository. This can include compiling code, running tests,
generating artifacts, and more.
Multiple Repositories: The plugin supports multiple Git repositories for a single Jenkins job. This is useful when your project depends on code from multiple
sources.
Change Logs: Jenkins can generate change logs that detail what code changes were included in a specific build. This is valuable for tracking the history of your builds
and releases.
Integration with Git Hosting Services: The Git Plugin integrates with various Git hosting services like GitHub, GitLab, Bitbucket, and more. You can easily configure
Jenkins to work with your preferred Git hosting platform.
Git Pull Request: A developer initiates a pull request when they want to update their local repository with changes from a remote repository. This often involves
fetching the latest changes made by others in the team.
Git Push Request: To push these commits to a remote repository, the developer initiates a push request with git push. This request asks the remote repository to
accept the local commits and update its branches accordingly.
To use the Git Plugin in Jenkins, you need to install it from the Jenkins Plugin Manager. Once installed, you can configure your Jenkins jobs to work with Git
repositories, specify build triggers, and define build actions based on your project's requirements. This enables continuous integration and automation in your
software development process, helping streamline code deployment and ensuring that your applications are built reliably and consistently.
UNIT - III
Parameter Plugin:
• The Parameter Plugin in Jenkins is a versatile and widely-used plugin that allows you to parameterize your Jenkins jobs. This means you can
customize job configurations by providing input parameters during job execution. It's a powerful feature for automating repetitive tasks,
making your builds more flexible, and facilitating interaction between Jenkins jobs and users.
Key features:
1. Parameter Types: The Parameter Plugin supports various parameter types that can be used to customize job executions. Common parameter
types include:
2. Choice Parameter: Provides a dropdown menu for users to select from predefined options.
5. Password Parameter: Safely stores sensitive information like API keys or credentials.
Dynamic Parameters: You can create dynamic parameters using Groovy scripts, which means that parameter options can be generated based
on external data, calculations, or the status of other jobs. This can be particularly useful for complex workflows.
Default Values: You can specify default values for parameters, making it easier for users who don't need to change the default configuration.
User-Friendly Interface: Users can set parameters directly through the Jenkins web interface when starting a job, making it accessible for users
who may not be familiar with Jenkins file syntax.
Integration with Other Plugins: The Parameter Plugin can be integrated with other Jenkins plugins to extend functionality, such as the Git
Plugin, allowing you to pass branch or commit parameters to your build process.
Pipeline Support: If you're using Jenkins Pipeline, you can also define parameters within your Jenkins file and customize pipeline behavior.
UNIT - III
• Configure a Jenkins job and add the desired parameters in the job configuration.
• Customize the job to use the parameters within build steps or post-build actions.
• When the job is executed, users will be prompted to provide parameter values.
The Parameter Plugin is valuable for creating flexible and user-friendly Jenkins jobs. It allows users to tailor job executions, input data, and
control build behavior, resulting in a more dynamic and versatile Jenkins environment.
UNIT - III
HTML Publisher:
The "HTML Publisher" plugin in Jenkins is a popular plugin used to publish HTML reports and documentation as a part of your Jenkins job's build artifacts. It allows
you to display and archive HTML content generated by your builds, making it accessible to users and team members.
Key features and use cases of the HTML Publisher plugin:
1. Publishing HTML Reports: The HTML Publisher plugin is primarily used for publishing HTML-based reports generated during the build process. These reports
could include test results, code analysis reports, documentation, or any other content that is generated in HTML format.
2. Customizable Report Display: You can customize the way reports are displayed in Jenkins. This includes specifying the report title, HTML directory containing the
reports, and the index page to display. This allows you to structure the presentation of your reports within Jenkins.
3. Historical Reports: Jenkins archives HTML reports from previous builds, allowing users to access historical data and track changes in reports over time. This is
especially useful for monitoring the progress of your project and identifying trends.
To use the HTML Publisher plugin in Jenkins:
4. Ensure the HTML Publisher plugin is installed on your Jenkins server.
5. In your Jenkins job configuration:
1. Add a post-build action to publish HTML reports.
2. Specify the HTML directory where your reports are generated.
3. Configure the report title, index page, and other display options.
6. When the Jenkins job is executed, the HTML reports will be published and accessible from the job's build page in Jenkins.
7. Users can click on the report links to view the HTML content directly within the Jenkins web interface.
UNIT - III
The "Copy Artifact" and "Extended Choice Parameter" plugins are two separate plugins commonly used in Jenkins to enhance and customize Jenkins job builds. Let's
take a closer look at each of these plugins:
Copy Artifact Plugin:
Functionality: The "Copy Artifact" plugin allows you to copy artifacts (files or directories) from one Jenkins job to another, or within the same job. Artifacts typically
include files generated in previous build steps or jobs, such as build outputs, archives, and reports.
Use Cases: This plugin is helpful in scenarios where you have a downstream job that depends on artifacts generated by an upstream job. You can use this plugin to
copy those artifacts to the location where they are needed in the downstream job.
Configuration: To use this plugin, you can add a "Copy artifacts from another project" build step in your Jenkins job's configuration. Specify the project and build
number from which you want to copy artifacts, and define the artifacts to copy. You can also set filtering criteria.
Extended Choice Parameter Plugin:
Functionality: The "Extended Choice Parameter" plugin extends Jenkins' built-in choice parameter by providing additional functionality for creating parameterized
builds with various types of choices. It allows you to create parameters that are more dynamic and flexible.
Use Cases: This plugin is useful when you need to create Jenkins job parameters that go beyond simple dropdown choices. It offers various parameter types such as
dropdowns, radio buttons, checkboxes, text boxes, etc. You can define choices from various sources, including scripts, properties files, or other jobs.
Configuration: To use this plugin, add an "Extended Choice Parameter" to your job configuration. Define the parameter type, choices, and any source scripts or
properties to generate the choices dynamically. This allows users to select different values as parameters for each build.
By combining these plugins, you can create complex, parameterized, and artifact-driven build processes that adapt to different
scenarios and requirements in your Jenkins environment. These plugins are particularly beneficial in projects with diverse
configurations and dependencies.
UNIT - III
To configure Jenkins to work with Java, you'll need to ensure that Jenkins has the necessary Java Runtime Environment (JRE) or Java
Development Kit (JDK) installed, and you may also need to set up environment variables and configure Jenkins jobs to use specific Java versions.
Install Java:
Ensure that Java (JRE or JDK) is installed on the machine where Jenkins is running. You can download Java from the official Oracle website or use
open-source alternatives like OpenJDK. Install the appropriate version of Java based on your project requirements.
It's a good practice to set the JAVA_HOME environment variable, which points to the directory where Java is installed. This can help Jenkins and
your build scripts locate the correct Java version.
Install Jenkins:
If Jenkins is not already installed, you need to set up Jenkins on your server. You can download Jenkins from the official website and follow the
installation instructions for your specific operating system.
UNIT - III
From the home page, click on the link Manage Jenkins and click on Configure System as shown below :
UNIT - III
From the next page, click on "Add JDK". The easiest way to configure JDK is to provide a name and path of the java installation directory.
(Consider the same path used for JAVA_HOME). In the below screenshot JDK 6 and JDK 7 has been configured,
NOTE : The Jenkins will validate to check whether the installation directory exists for the specified JDK versions.
UNIT - III
JDK can also be installed by intimating Jenkins to do the task. The check box install automatically needs to be checked in this case. Jenkins will
download and installs the specified version of the JDK into the tools directory of the Jenkins home directory.
After all the settings made to configure the JDK, just click the "Save" at the bottom of the page to save the configuration.
UNIT - III
Git and Maven are two essential tools in the software development and build process. Here's how they are used and how they can work
together:
Git:
• Git is a distributed version control system (VCS) used for tracking changes in source code during software development.
• It allows multiple developers to work on the same project simultaneously without interfering with each other's work.
• Git helps manage different versions or branches of a project, making it easy to collaborate, track changes, and merge code from different
contributors.
• It is used for source code management, and it's particularly effective for versioning text-based files like source code, configuration files, and
documentation.
Maven:
• Maven is a build automation and project management tool used in Java-based projects.
• It simplifies the build process by managing project dependencies, compiling source code, running tests, and packaging the application into
distributable formats (e.g., JAR or WAR files).
• Maven uses a configuration file called the Project Object Model (POM) to define the project's structure, dependencies, plugins, and goals.
• It helps automate repetitive tasks and ensures that your project is built consistently and according to predefined goals.
UNIT - III
Dependency Management: Maven simplifies the process of managing project dependencies. It can retrieve dependencies from various sources, including Git
repositories. When specifying dependencies in your POM file, you can reference libraries hosted on Git repositories, such as GitHub or GitLab.
Building Java Projects: If you're working on a Java project, you can use Maven to define and automate the build process. Maven downloads required libraries,
compiles source code, runs tests, and packages the application. Git is used for version control during development.
Continuous Integration (CI): Git and Maven are commonly used in CI/CD (Continuous Integration/Continuous Delivery) pipelines. For example, Jenkins, a popular CI
tool, can be configured to automatically build a project using Maven whenever changes are pushed to a Git repository. This ensures that code is built and tested
consistently, helping identify issues early.
Release Management: Maven simplifies the process of releasing software. You can use Maven's release plugin to prepare and perform releases, updating version
numbers, creating release branches, and publishing artifacts. Git tags can also be used to mark specific versions in the repository.
Integration with Source Control: While Git is the primary tool for version control, Maven can work seamlessly alongside it. Developers commit and push code
changes using Git, and the CI/CD pipeline triggers builds using Maven.
Git and Maven serve different but complementary roles in software development. Git manages source code and tracks changes, while Maven handles project builds,
dependencies, and automation. They are often used together to streamline the development and release process for Java-based projects.
UNIT - III
Creating a Jenkins build job and workspace involves setting up a Jenkins job that can build and compile your project's source
code. The workspace in Jenkins is a directory on the server where Jenkins stores files related to a specific job. Here are the
steps to create a Jenkins build job and workspace:
Prerequisites:
2. You should have a source code repository (e.g., Git or SVN) that Jenkins can access.
5. Enter a name for your job, choose the "Freestyle project" option, and click "OK.“