Jenkins Basics Notes
Jenkins Basics Notes
l
Continuous Integration is a software development method where team members integrate their
lo
work at least once a day. In this method, every integration is checked by an automated build to
detect errors. This concept was first introduced over two decades ago to avoid "integration hell,"
which happens when integration is put off till the end of a project.
x.
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.
• le
In this CI tutorial, you will learn:
l
Difficult integration Easy and Effective
lo
Integration
x.
and often.
l
lo
x.
le
ip
Activities in Continuous Integration
.a
While compilation only compiles a code, CI does the following activities
DB integration:
w
Code Inspection:
w
Automated Deployment:
• Allows you to release product anytime
• Continually demo-able state and it is works on any machine
Compilation:
l
lo
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.
When do I build?
x.
• At every check-in
• Every time a dependency changes
How do I build?
le
ip
.a
w
w
w
CI process
• Ideally, the build should come from the command line and should not depend on IDE.
• The build should happen continuously using a dedicated Cl server, not a cron job.
• CI built should be triggered on every check-in and not just at midnight
• The build should provide immediate feedback and Require no developer effort
l
lo
x.
le
ip
Here, are the key elements which you need to perfom the entire CI process:
• Version Control System (VCS): It offers a reliable method to centralize and preserve changes
.a
made to your project over time.
• Virtual Machine: You should have a spare server or at least one virtual machine to build your
system.
• Hosted CI Tool Solutions: To avoid servers or virtual machines, you should go for hosted CI tool
solutions. This tool helps in the maintenance of the whole process and offers easier scalability.
w
• Tools: If you select a self-hosted variant, you will need to install one of the many CI tools like
Jenkins, TeamCity, Bamboo, GitLab, etc.
You are surely aware of the old phone Nokia. Nokia used to implement a procedure called
nightly build. After multiple commits from diverse developers during the day, the software built
w
every night. Since the software was built only once in a day, it's a huge pain to isolate, identify,
and fix the errors in a large codebase.
Later, they adopted the Continuous Integration approach. The software was built and tested as
soon as a developer committed code. If any error is detected, the respective developer can
quickly fix the defect.
l
lo
Here, are some important best practices while implementing
x.
• Act on metrics
• Build-in every target environment Create artifacts from every build
• The build of the software need to be carried out in a manner so that it can be automated
• Do not depend on an IDE
• Build and test everything when it changes
•
•
•
• le
The database schema counts as everything
Helps you to find out key metrics and track them visually
Check-in often and early
Stronger source code control
ip
• Continuous integration is running unit tests whenever you commit code
• Automate the build and test everyone
• Keep the build fast with automated deployment
.a
Disadvantages of CI
Here, are cons/drawbacks of Continuous Integration process:
w
• Initial setup time and training is required to get acquainted with Cl server
• Development of suitable test procedures is essential
• Well-developed test-suite required many resources for Cl server
• Conversion of familiar processes
w
l
lo
Jenkins is an open-source continuous integration software. It is written using the Java
programming language. It facilitates real-time testing and reporting on isolated changes in a
more massive codebase. This software helps developers to quickly find and solve defects in their
codebase & automate testing of their builds.
x.
Bamboo:
le
Bamboo is a continuous integration build server that performs - automatic build, test, and
releases in a single place. It works seamlessly with JIRA software and Bitbucket. Bamboo
ip
supports many languages and technologies such as CodeDeply, Ducker, Git, SVN, Mercurial,
AWS, and Amazon S3 buckets.
TeamCity:
.a
w
TeamCity is a Continuous Integration server that supports many powerful features. It maintains a
w
CI server healthy and stable even when no builds are running. It provides better code quality for
any project
Summary:
w
l
and Commit Often never Commit Broken Code
• The major drawback of the CICD pipeline process is that well-developed test-suite required
lo
many resources for Cl server
• Jenkins, Bambook, and Team City are some useful AWS Continuous Integration tools.
x.
le
ip
.a
w
w
w
l
lo
Jenkins is an open-source Continuous Integration server written in Java for orchestrating a chain
of actions to achieve the Continuous Integration process in an automated fashion. Jenkins
supports the complete development life cycle of software from building, testing, documenting
the software, deploying, and other stages of the software development life cycle.
x.
Jenkins is a widely used application around the world that has around 300k installations and
growing day by day. By using Jenkins, software companies can accelerate their software
development process, as Jenkins can automate build and test at a rapid rate.
le
It is a server-based application and requires a web server like Apache Tomcat. The reason
Jenkins software became so popular is that of its monitoring of repeated tasks which arise during
the development of a project. For example, if your team is developing a project, Jenkins will
ip
continuously test your project builds and show you the errors in early stages of your
development.
code commit, code is built and tested. If the test is passed, the build is tested for deployment. If
the deployment is successful, the code is pushed to production.
This commit, build, test, and deploy is a continuous process and hence the name continuous
integration/deployment.
l
• Continuous Integration Server (Jenkins, Bamboo, CruiseControl, TeamCity, and others)
lo
• Source Control Tool (e.g., CVS, SVN, GIT, Mercurial, Perforce, ClearCase and others)
• Build tool (Make, ANT, Maven, Ivy, Gradle, and others)
• Automation testing framework (Selenium, Appium, TestComplete, UFT, and others)
x.
Jenkin History
• Kohsuke Kawaguchi, a Java developer, working at SUN Microsystems, was tired of building the
code and fixing errors repetitively. In 2004, created an automation server called Hudson that
• le
automates build and test task.
In 2011, Oracle who owned Sun Microsystems had a dispute with Hudson open source
community, so they forked Hudson and renamed it as Jenkins.
Both Hudson and Jenkins continued to operate independently. But in short span of time, Jenkins
ip
acquired a lot of projects and contributors while Hudson remained with only 32 projects. With
time, Jenkins became more popular, and Hudson is not maintained anymore.
Let us imagine, that there are around 10 developers who are working on a shared repository.
Some developer completes their task in 25 days while others take 30 days to complete.
l
errors to the developer
lo
team.
x.
all at once, some immediately after any
developers would need of the Developer
to wait until other commits.
developers finish coding
le
to check their build
l
nightly build. After multiple commits from diverse developers during the day, the software built
lo
every night. Since the software was built only once in a day, it's a huge pain to isolate, identify,
and fix the errors in a large code base.
Later, they adopted Continuous Integration approach. The software was built and tested as soon
as a developer committed code. If any error is detected, the respective developer can quickly fix
x.
the defect.
le
ip
.a
w
w
w
Jenkins Plugins
By default, Jenkins comes with a limited set of features. If you want to integrate your Jenkins
installation with version control tools like Git, then you need to install plugins related to Git. In
l
lo
x.
le
ip
Plugins integration in Jenkins
• Jenkins is being managed by the community which is very open. Every month, they hold public
meetings and take inputs from the public for the development of Jenkins project.
w
• So far around 280 tickets are closed, and the project publishes stable release every three
months.
• As technology grows, so does Jenkins. So far Jenkins has around 320 plugins published in its
plugins database. With plugins, Jenkins becomes even more powerful and feature rich.
•
w
Jenkins tool also supports cloud-based architecture so that you can deploy Jenkins in cloud-
based platforms.
• The reason why Jenkins became popular is that it was created by a developer for developers.
• Its interface is out dated and not user friendly compared to current UI trends.
• Though Jenkins is loved by many developers, it's not that easy to maintain it because Jenkins
runs on a server and requires some skills as server administrator to monitor its activity.
Conclusion:
•
l
In Continuous Integration, after a code commit, the software is built and tested immediately
• Jenkins used for orchestrating a chain of actions for Continuous Integration in a software project
lo
• Before Jenkins when all Developers had completed their assigned coding tasks, they used to
commit their code all at same time. Later, Build is tested and deployed.
• After Jenkins the code is built and test as soon as Developer commits code. Jenkin will build and
test code many times during the day
x.
• By default, Jenkins comes with a limited set of features. If you want to integrate your Jenkins
installation with version control tools like Git, then you need to install plugins related to Git
• The biggest pros of Jenkins is that it is managed by the community which holds public meetings
and take inputs from the public for the development of Jenkins projects
• The biggest con of Jenkin is that Its interface is out dated and not user friendly compared to
le
current UI trends.
ip
.a
w
w
w
l
lo
Prerequisites:
Before you proceed to install Jenkins in your windows system, there are some prerequisites for
Jenkins to install Jenkins in your computer.
x.
Hardware requirements:
• You need minimum 256 MB of RAM in your computer or laptop to install Jenkins
• You need at least 1 GB of space in your hard drive for Jenkins.
• le
Software Requirements:
Since Jenkins runs on Java, you need either latest version of Java Development Kit (JDK) or Java
ip
Runtime Environment (JRE).
Release Types
.a
Jenkins releases two types of versions based on the organization needs.
Long-term support releases are available every 12 weeks. They are stable and are widely tested.
This release is intended for end users.
w
Weekly release:
Weekly releases are made available every week by fixing bugs in its earlier version. These
w
We will use the LTS release though the process remains the same for Weekly release.
Step 1) Got to https://www.jenkins.io/download/ and select the platform. In our case Windows
l
lo
x.
le
ip
.a
w
w
w
Step 2) Go to download location from local computer and unzip the downloaded package.
Double-click on unzipped jenkins.msi. You can also Jenkin using a WAR (Web application
ARchive) but that is not recommended.
l
lo
x.
le
ip
.a
w
Step 4) Choose the location where you want to have the Jenkins instance installed (default
location is C:\Program Files (x86)\Jenkins), then click on Next button.
w
w
l
lo
x.
le
ip
Step 7) During the installation process an info panel may pop-up to inform the user that for a
complete setup, the system should be rebooted at the end of the current installation. Click on OK
.a
button when the Info panel is popping-up:
w
w
After completing the Jenkins installation phase, you should proceed further and start its
configuration. Next steps will guide you how you can unblock Jenkins application:
http://localhost:8080
If you can access the above URL, then it confirms that Jenkins is successfully installed in your
system.
l
lo
x.
le
ip
.a
w
Step 2) The initial Administrator password should be found under the Jenkins installation path
w
However, If a custom path for Jenkins installation was selected, then you should check that
location for initialAdminPassword file.
Step 1) Click on the "Install suggested plugins button" so Jenkins will retrieve and install the
essential plugins
w
w
w
l
lo
x.
le
ip
.a
Step 3) Once you have filled the above data, finally it will ask for URL information where you
can configure the default instance path for Jenkins. Leave it as it is to avoid any confusions later.
However, if another application is already using 8080 port, you can use another port for Jenkins
and finally save the settings, and you are done with installation of Jenkins. Hit the "Save and
w
Continue" button:
w
w
Jenkins has outstanding plugin support. There are thousands of third-party application plugins
available on their website. To know if Jenkins supports the third-party applications you have in
l
mind, check their plugins directory at https://plugins.jenkins.io/.
lo
x.
In this Jenkins tutorial, you will learn:
•
•
• le
Installation of Plugins in Jenkins
How to Install Git Plugin in Jenkins
How to Integrate Jenkins With GitHub
ip
Installation of Plugins in Jenkins
Jenkins comes with a pretty basic setup, so you will need to install the required plugins to enable
.a
respective third-party application support.
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
w
Jenkins needs to have GitHub plugin installed to be able to pull code from the GitHub repository.
w
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.
w
le
ip
.a
w
w
w
l
lo
x.
Step 4: Once the plugins have been installed, go to Manage Jenkins on your Jenkins dashboard.
You will see your plugins listed among the rest.
le
ip
.a
w
Step 1) Create a new job in Jenkins, open the Jenkins dashboard with your Jenkins URL. For
example, http://localhost:8080/
w
lo
an example.
x.
le
ip
Step 3) Once you click OK, the page will be redirected to its project form. Here you will need to
enter the project information:
.a
w
w
w
Step 4) You will see a Git option under Source Code Management if your Git plugin has been
installed in Jenkins:
x.
Step 5) Enter the Git repository URL to pull the code from GitHub.
le
ip
.a
w
Step 6) You might get an error message the first time you enter the repository URL. For
example:
w
w
This happens if you do not have Git installed in your local machine. To install Git in your local
machine, go to https://git-scm.com/downloads
le
ip
.a
w
w
w
Step 7) You can execute Git repositories in your Jenkins once Git has been installed on your
machine. To check if it has been successfully installed onto your system, open your command
prompt, type "Git" and press enter. You should see different options come up for Git:
x.
Note: If you have GIT already installed in your system, just add git.exe path in Global Tool
Configuration.
Step 8) Once you have everything in place, try adding the Git URL into Jenkins. You will not
le
see any error messages for Jenkins Git integration:
ip
.a
w
l
Generally, in a large organization, there are multiple, separate teams to manage and run jobs in
lo
Jenkins. But managing this crowd of users and assigning roles to them can prove troublesome.
By default, Jenkins comes with very basic user creation options. You can create multiple users
but can only assign the same global roles and privileges to them. This not ideal, especially for a
large organization.
x.
The Role Strategy Plugin enable you to assign different roles and privileges to different
users. You will first need to install the plugin in your Jenkins mange environment.
•
•
le
In this Jenkins tutorial, you will learn
If you haven't installed Jenkins in your local server, go to the appropriate URL and access your
w
You will now see options to create and add user in Jenkins and manage current users.
•
•
• le
Step 3) Create a new User
You will see on the dashboard that a new Jenkins create user as per the details entered.
lo
There are two methods for installing plugins in Jenkins:
x.
2. Downloading the plugin from Jenkins website and installing it manually.
Step 1)
le
1. Go to Manage Jenkins
Step 2)
l
lo
x.
Step 3)
le
ip
.a
w
w
Following are the steps on how to manage and assign roles in Jenkins:
Step 1)
1. Go to Manage Jenkins
l
lo
x.
le
ip
.a
Note: that the Manage and Assign Roles option will only be visible if you've installed the role
strategy plugin.
w
Step 2) Click on Manage Roles to add new roles based on your organization.
w
w
1.
2.
3.
4.
le
Type "developer" under "role".
Click on "Add" to create a new role.
Now, select the Jenkins user permissions you want to assign to the "Developer" role.
Click Save
ip
.a
w
w
w
1. Go to Manage Jenkins
2. Select Manage and Assign Roles
le
1. Selector developer role checkbox
2. Click Save
ip
.a
w
w
w
You can assign any role to any user, as per your need.
l
2. Add a pattern to this by adding tester.*, so that any username starting with "tester" will be
assigned the project role you specify.
lo
3. Click Add
4. Select privileges
5. Click Save
x.
le
ip
.a
w
w
w
l
lo
Jenkins Freestyle Project is a repeatable build job, script, or pipeline that contains steps and
post-build actions. It is an improved job or task that can span multiple operations. It allows you
to configure build triggers and offers project-based security for your Jenkins project. It also
offers plugins to help you build steps and post-build actions.
x.
The types of actions you can perform in a Jenkins build step or post-build action are quite
limited. There are many standard plugins available within a Jenkins Freestyle Project to help you
overcome this problem.
le
ip
.a
How to Create a Job in Jenkins
The freestyle build job is a highly flexible and easy-to-use option. You can use it for any type of
project; it is easy to set up, and many of its options appear in other build jobs. Below is a step by
step process to create job in Jenkin.
w
To create a Jenkins freestyle job, log on to your Jenkins dashboard by visiting your Jenkins
installation path. Usually, it will be hosted on localhost at http://localhost:8080 If you have
w
installed Jenkins in another path, use the appropriate URL to access your dashboard as shown in
the below Jenkins job creation example.
le
ip
.a
w
w
1. Enter the name of the item you want to create. We shall use the "Hello world" for this demo.
2. Select Freestyle project
3. Click Okay
Under Source Code Management, Enter your repository URL. We have a test repository located
at https://github.com/kriru/firstJava.git
ip
.a
w
w
w
If your GitHub repository is private, Jenkins will first validate your login credentials with
GitHub and only then pull the source code from your GitHub repository.
Now that you have provided all the details, it's time to build the code. Tweak the settings under
the build section to build the code at the time you want. You can even schedule the build to
happen periodically, at set times.
Under build,
l
1. Click on "Add build step"
lo
2. Click on "Execute Windows batch command" and add the commands you want to execute
during the build process.
x.
le
ip
.a
Here, I have added the java commands to compile the java code.
w
javac HelloWorld.java
w
java HelloWorld
w
1. Click Apply
le
When you have entered all the data,
Now, in the main screen, Click the Build Now button on the left-hand side to build the source
code.
.a
w
w
w
l
lo
x.
le
ip
Step 10) See the console output
.a
Click on the build number and then Click on console output to see the status of the build you
run. It should show you a success message, provided you have followed the setup properly as
shown in the below Jenkins create new job example.
w
w
w
• The types of actions you can perform in a build step or post-build action are quite limited. There
are many standard plugins available within a Jenkins Freestyle Project to help you overcome this
problem.
• Freestyle build Jenkins jobs are highly flexible and easy-to-use. You can use it for any type of
w
project; it is easy to set up, and many of its options appear in other build Jenkins jobs.
• If your GitHub repository is private, Jenkins will first validate your login credentials with GitHub
and only then pull the source code from your GitHub repository.
w
l
What is Jenkins Pipeline?
lo
Jenkins Pipeline is a combination of plugins that supports integration and implementation of
continuous delivery pipelines. It has an extensible automation server to create simple and
x.
complex delivery pipelines as code via pipeline DSL. A Pipeline is a group of events interlinked
with each other in a sequence.
le
In a Jenkins pipeline, every job or event has some sort of dependency on at least one or more
events.
ip
.a
Working
of Jenkins Continuous Delivery Pipelines
w
The picture above represents a continuous delivery pipeline in Jenkins. It contains a group of
states called build, deploy, test and release. These events are interlinked with each other. Every
state has its events, which work in a sequence called a continuous delivery pipeline.
w
A continuous delivery pipeline is an automated expression to display your process for getting
software for version control. Thus, every change made in your software goes through a number
of complex processes on its way to being released. It also involves developing the software in a
reliable and repeatable manner, and progression of the built software through multiple stages
w
What is a JenkinsFile?
l
Jenkins pipelines can be defined using a text file called JenkinsFile. You can implement
lo
pipeline as code using JenkinsFile, and this can be defined by using a domain specific language
(DSL). With JenkinsFile, you can write the steps needed for running a Jenkins pipeline.
x.
• You can create pipelines automatically for all branches and execute pull requests with just
one JenkinsFile.
• You can review your Jenkins code on the pipeline
•
•
le
You can audit your Jenkins pipeline
This is the singular source for your pipeline and can be modified by multiple users.
There are two types of Jenkins pipeline syntax used for defining your JenkinsFile.
.a
1. Declarative
2. Scripted
Declarative:
w
Declarative pipeline syntax offers an easy way to create pipelines. It contains a predefined
hierarchy to create Jenkins pipelines. It gives you the ability to control all aspects of a pipeline
execution in a simple, straight-forward manner.
w
Scripted:
Scripted Jenkins pipeline runs on the Jenkins master with the help of a lightweight executor. It
uses very few resources to translate the pipeline into atomic commands. Both declarative and
w
scripted syntax are different from each other and are defined totally differently.
Here are the reasons why you use should use Jenkins pipeline:
l
• Jenkins pipeline is implemented as a code which allows multiple users to edit and execute the
lo
pipeline process.
• Pipelines are robust. So if your server undergoes an unforeseen restart, the pipeline will be
automatically resumed.
• You can pause the pipeline process and make it wait to resume until there is an input from the
x.
user.
• Jenkins Pipelines support big projects. You can run multiple jobs, and even use pipelines in a
loop.
l
and create triggers which require manual intervention.
lo
Here is how you can install the build pipeline plugin in your Jenkins:
x.
Manage Jenkins > Manage Plugins.
le
ip
.a
If you have already installed the plugin, it is shown under the installed tab.
w
w
w
Once you have successfully installed the build pipeline plugin in your Jenkins, follow these
steps to create your Jenkins pipeline:
l
lo
Once you are logged in to your Jenkins dashboard:
Step 1) Click on the "+" button on the left-hand side of your Jenkins dashboard to create a
pipeline.
x.
le
ip
Step 2)
1. You will be asked to give a name to the pipeline view. We shall call it "Guru99 Pipeline" for the
duration of this demo.
.a
2. Select Build a pipeline view under options
3. Click ok
w
w
w
l
lo
x.
le
ip
.a
This will show you the sample pipeline view of your item, as given below:
w
w
w
Step 3) Install the Build Pipeline view plugin if you don't have it installed already.
w
Step 4) Go to your Jenkins dashboard and create a view by clicking on the "+" button. Select
the Build Pipeline View option and click OK.
w
w
When the Jenkins pipeline is running, you can check its status with the help of Red and Green
status symbols. Red means the pipeline has failed, while green indicates success.
In this Jenkins pipeline example, we see that the button is green. Hence, the pipeline is
successful.
l
lo
x.
le
ip
Running Jenkins pipeline
.a
Click on Run to run the Jenkins pipeline. It will look something like this:
w
w
In the Jenkins pipeline script example above, we are demonstrating a simple "helloworld.java"
program. But in real time projects, you will be responsible for creating and building complex
pipelines in Jenkins. See below for a sample pipeline view.
w
l
A CI/CD pipeline automates the process of software delivery. It builds code, runs tests, and helps
lo
you to safely deploy a new version of the software. CI/CD pipeline reduces manual errors,
provides feedback to developers, and allows fast product iterations.
CI/CD pipeline introduces automation and continuous monitoring throughout the lifecycle of a
x.
software product. It involves from the integration and testing phase to delivery and deployment.
These connected practices are referred as CI/CD pipeline.
•
le
Continuous Deployment?
Continuous integration is a software development method where members of the team can
integrate their work at least once a day. In this method, every integration is checked by an
ip
automated build to search the error.
• Continuous delivery is a software engineering method in which a team develops software
products in a short cycle. It ensures that software can be easily released at any time.
• Continuous deployment is a software engineering process in which product functionalities are
.a
delivered using automatic deployment. It helps testers to validate whether the codebase
changes are correct, and it is stable or not.
l
lo
x.
Stages of
CI/CD pipeline
Source Stage
le
In the source stage, CI/CD pipeline is triggered by a code repository. Any change in the program
triggers a notification to the CI/CD tool that runs an equivalent pipeline. Other common triggers
include user-initiated workflows, automated schedules, and the results of other pipelines.
ip
Build Stage
This is the second stage of the CI/CD Pipeline in which you merge the source code and its
.a
dependencies. It is done mainly to build a runnable instance of software that you can potentially
ship to the end-user.
Programs that are written in languages like C++, Java, C, or Go language should be compiled.
On the other hand, JavaScript, Python, and Ruby programs can work without the build stage.
w
Failure to pass the build stage means there is a fundamental project misconfiguration, so it is
better that you address such issue immediately.
w
Test Stage
Test Stage includes the execution of automated tests to validate the correctness of code and the
w
behaviour of the software. This stage prevents easily reproducible bugs from reaching the clients.
It is the responsibility of developers to write automated tests.
Deploy Stage
This is the last stage where your product goes live. Once the build has successfully passed
through all the required test scenarios, it is ready to deploy to live server.
• Source Code Control: Host code on GitHub as a private repository. This will help you to integrate
your application with major services and software.
• Continuous integration: Use continuous integration and delivery platform CircleCI and commit
l
every code. When the changes notify, this tool will pull the code available in GitHub and process
to build and run the test.
lo
• Deploy code to UAT: Configure CitcleCI to deploy your code to AWS UAT server.
• Deploy to production: You have to reuse continuous integration steps for deploying code to
UAT.
x.
CI/CD pipeline Best Practices
Here is a CI/CD pipeline best practices:
•
le
Write up the current development process therefore, you can know the procedures that require
to change and one that can be easily automated.
Start off with a small proof of project before going ahead and complete whole development
process at once.
ip
• Set up a pipeline with more than one stage in which fast fundamental tests run first.
• Start each workflow from the same, clean, and isolated environment.
• Run open source tools that cover everything from code style to security scanning.
• Setup a better code hub to continuously check the quality of your code by running the standard
.a
set of tests against every branch.
• Peer code review each pull request to solve a problem in a collaborative manner.
• You have to define success metrics before you start the transition to CD automation. This will
help you to consistently analyze your software, developing progress help refining where
needed.
w
l
lo
Here are the important CI/CD tools:
Jenkins
x.
le
Jenkins is an open-source Continuous Integration server that helps to achieve the Continuous
Integration process (and not only) in an automated fashion. Jenkins is free and is entirely written
ip
in Java. Jenkins is a widely used application around the world that has around 300k installations
and growing day by day.
Features:
.a
• Jenkin will build and test code many times during the day.
• Automated build and test process, saving timing, and reducing defects.
• The code is deployed after every successful build and test.
• The development cycle is fast.
w
Link: https://www.jenkins.io/download/
w
Bambo
w
Bamboo is a continuous integration build server that performs - automatic build, test, and
releases in a single place. It works seamlessly with JIRA software and Bitbucket.
Features:
Link: https://www.atlassian.com/software/bamboo
l
lo
CircleCI
x.
le
Circle CI is a flexible CI tool that runs in any environment like a cross-platform mobile app,
Python API server, or Docker cluster. This tool reduces bugs and improves the quality of the
application.
ip
Features:
Link: https://circleci.com/
w
• Project managers can publish push application components to services like web services,
database services, API services, etc.
• Providing log data and alerts on the delivery state.
• It enables programmers to verify code changes before they move forward, reducing the chances
of defects ending up in production.
l
when found. Such a metric is an overall measure of your team efficiency.
lo
• Change Lead Time: It measures the start time of the development phase to deployment. This
metric is an indicator of the entire development process and how well the team works together.
• Change Failure Rate: It focuses on the number of times development get succeeds vs. the
number of times it fails.
x.
• MTTR vs. MTTF: MTTR (Mean Time to Recovery) is the amount of time required by your team to
recover from failure. MTTF (Mean Time to Failure) measures the amount of time between fixes
and outages. These metrics are a reflection of the team's ability to respond and fix issues.
Summary
•
•
le
A CI/CD pipeline automates the process of software delivery.
CI/CD pipeline introduces automation and continuous monitoring throughout the lifecycle of a
ip
software product.
• Continuous integration is a software development method where members of the team can
integrate their work at least once a day.
• Continuous delivery is a software engineering method in which a team develops software
products in a short cycle.
.a
• Continuous deployment is a software engineering process in which product functionalities are
delivered using automatic deployment.
• There are four stages of a CI/CD pipeline 1) Source Stage, 2) Build Stage, 3) Test Stage, 4) Deploy
Stage.
• Important CI/CD tools are Jenkins, Bambo, and Circle CI.
w
• Change Lead Time measures the start time of the development phase to deployment.
• Change Failure Rate focuses on the number of times development get succeeds vs. the number
of times it fails.
• MTTR (Mean Time to Recovery) is the amount of time required by your team to recover from
w
failure.
• MTTF (Mean Time to Failure) measures the amount of time between fixes and outages.
l
What is CI?
lo
Continuous integration is a software development method where members of the team can
integrate their work at least once in a day. In this method, every integration is checked by an
x.
automated build to search the error. The CI concept was first introduced over two decades ago to
avoid "integration hell," which happens when integration is put off till the end of a project.
•
•
•
•
What is CI?
le
What is Travis CI?
What is Jenkins?
What does Travis do?
ip
• What did Jenkin do?
• Travis CI Features:
• Jenkin Features:
• Travis vs. Jenkins
.a
• Popularity Index
• Which is better?
How CI works?
w
Travis CI tool can easily integrate with the common cloud repositories like GitHub and
Bitbucket. It offers many automated CI options which cut out the need for a dedicated server as
the Travis CI server is hosted in the cloud. This allows you to test in different environments, on
w
Travis CI is free for open source projects. For commercial projects, you need to purchase an
enterprise plan.
w
What is Jenkins?
Jenkins is an award-winning continuous integration tool that monitors executions of deployment
cycles. It started as a side project by Sun's software engineers group. Later it was expanded as
one of the popular open source CI tools which help software development teams to automate
their deployments.
In this tool, Developers can also specify conditions for customized builds. Jenkins supports a
massive plugin archive. This allows developers to alter how Jenkin looks and operates.
Moreover, the Jenkins Pipeline suite of plugins comes with special tools that allow developers to
model easy-to-complex delivery pipelines using DSL ( Digital Subscribe line) method.
l
What does Travis do?
lo
Travis CI offers following benefits:
x.
• You can monitor GitHub projects
• Runs Test and generate results quickly. Parallel test execution is possible.
• Build artifacts & check code quality
• Easy Deployment to cloud services
•
•
•
le
It can identify small as well as large code changes.
Developers can use Travis CI to watch the tests when they are running.
The tool integrates with Slack, HipChat, Email, etc.
Travis CI Features:
• Automatic integration with GitHub
w
l
• Jenkins provides remote access API and its functionalities.
lo
• Provide Powerful CI/CD tool for big projects
• It supports various job models like Freestyle, Pipeline, etc.,
• Allows developers to add their extensions
• Compatible with Docker, Libvirt, Kubernetes, and many other programs
x.
Travis vs. Jenkins
Parameter Jenkin Travis
Cost le
Jenkins is free. But
development team
need to run and
maintain their
Travis CI enterprise
suites start at $129
per month. Cost
ip
increase based on the
dedicated server. This
level of support you
could be considered an
require.
extra expense.
.a
Jenkins needs
It takes very less time
elaborate setup. So
to get started. Create
Set up Time you'll have a very long
a config file and start
wait time for the
integrating.
complete installation.
w
working in an open
then Jenkins is the best
source project.
choice for you.
It is an open-source It is a commercial CI
w
Tool Type
free to use the tool. Tool
• Integration
with GitHub
& cloud
• Customization
• Unlimited
l
is biggest
open source
lo
benefit of the
projects with
Jenkins CI
full
server
functionality
• Extensive
• An extensive
x.
project
plugin archive
configuration
can be
via .travis.ymi
configured to
Pros file
change the
• Allows cluster
le look of Jenkins.
• The biggest
w
integration is Commercial
that it is highly plans start at
configurable. $129/m
Cons There is no which is quite
w
out-of-the-box expensive.
setup. That's • Not suitable
why it may for high-
take two-three security
hours to days projects
to get • Unlike other
everything CI tools, it
does not
configured in offer
the system. Bitbucket
Support.
l
Paid for Enterprise.
lo
Server
Server-based Cloud-based
Machine
Customization
x.
More Less
Options
Control on
system
Full
l
lo
x.
le
ip
.a
w
w
w
l
What is Continuous Integration?
lo
Continuous integration is a software development method where members of the team can
integrate their work at least once a day. In this method, every integration is checked by an
x.
automated build to search the error.
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
le
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.
delivered using automatic deployment. It helps testers to validate whether the codebase changes
are correct and stable or not.
The team can achieve continuous deployment by relying on infrastructure that automates
w
different testing steps. Once each integration meets this release criteria, the application is
updated with a new code.
l
in Continuous Deployment, developers deploy the code directly to the production stage when it
is developed.
lo
• CI uses unit tests on the contrary Continuous Delivery uses business logic tests. In Continuous
Deployment any testing strategy is used.
• CI refers to the versioning of source code whereas Continuous Delivery refers to the logical
evolution of CI and Continuous Deployment refers to automated implementations of the source
x.
code.
Difference between CI vs CD vs CD
Continuous
integration le
Here is an important difference between CI vs CD vs CD.
Continuous
Delivery
Continuous
Deployment
ip
CD is an
CI is an approach
approach to CD is an approach
of testing each
obtain changes to develop
change to
.a
of new features, software in a short
codebase
configuration, cycle.
automatically.
and bug fixes.
CD refers to
w
CI focuses on
automation
Focuses on Emphasis on the
testing to
releasing new change in all stages
determine that
w
l
It helps you to It allows It enables you to
identify and developers to rapidly deploy and
lo
rectify issues check software validate new
early. updates. features and ideas.
Any testing
x.
It uses business
It uses unit tests. strategy is
logic tests.
performed.
Development
team sends
merging
le
continuous code You deliver code
for review that
requests even can be batched
Deploy code using
an automated
process.
ip
when the testing for release.
process is
running.
You require a
.a
You require a
continuous
strong
integration You need a good
foundation in
server to testing culture.
continuous
monitor the
integration.
w
main repository.
l
CI offers code stability.
lo
Advantages of Continuous Delivery
Here are the pros/benefits of continuous delivery:
x.
• Automate the software release process for making delivery more efficient, rapid, and secure.
• CD practices increase productivity by freeing developers from manual work and complex
dependencies.
• It helps you to discover software bugs early in the delivery process.
•
•
•
le
CD helps your business team to deliver updates to clients immediately and frequently.
It ensures the software is always ready to go to production.
You can release software more frequently, which helps you to get fast feedback from your
clients.
ip
• There is less pressure on decisions for small changes.
• Initial setup time and training is required to get acquainted with Cl server
• Well-developed test-suite required many resources for Cl server.
• It requires additional servers and environments.
• You need a conversion of familiar processes in one project.
l
lo
Here are the cons/disadvantages of continuous delivery:
• You should know continuous integration practices before you go for continuous delivery.
• Deployments are still manual, and hence it takes lots of time to deliver the software product.
x.
• The automated tests should be written and function properly.
• Faulty tests can lead to damage while quality testing.
• It requires team coordination because code changes should be collected regularly in an efficient
way.
• Continuous delivery requires a reliable and strong integration server for the automation test
le
that is costly.
• Your testing culture should be good as the quality of the suite determines how good software
.a
releases are.
• Documentation procedures need to keep up with deployment pace.
• Releasing significant changes needs assurance by marketing, help, and support, and other
departments.
w
• Automate Deployment
• Commit early and often.
• You should never commit broken code
• Fix build failures immediately.
• Build-in every target environment Create artifacts from every build
• The build of the software needs to be carried out in a manner so that it can be automated
• Do not depend on an IDE
• Build and test everything when it changes
l
Continuous Delivery Best Practices
lo
Here are some important best practices while implementing continuous delivery:
x.
• Each stage should trigger the next one quickly upon successful completion.
• Maintain the version of the source code.
• Perform automated build and Deployment.
• Deploy to one instance of a virtual machine at a time.
• Perform unit and integration tests.
•
•
•
• le
You have to build your library only once.
The team should use the same automated release method for each and every environment.
This method enables you to eliminate conflicts and last-minute problems.
In case any state fails, you should automatically pause the process and fix the issues.
ip
Continuous Deployment Best Practices
.a
Here are some important best practices while implementing continuous Deployment:
• When software is ready for the Deployment, you can create a pull request for the branch.
• Deployment software to pre-production staging servers.
• Promote your software once you are happy with its quality.
w
• You need to keep the continuous delivery efficient without bothering the time.
• You need to cope up with tight deadlines release plan.
• Poor product-specific communication of teams may lead to revisions as well as deployment
l
delays.
• The business team should have the budget to have the infrastructure needed to build more
lo
impressive software.
• Monitoring data/ information should be utilized by the research and development team.
• The organization should ensure that how open source software fits into the current workflow.
x.
Challenges of Continuous Deployment
Here are the challenges of continuous deployment:
•
le
CD requires continuous planning to achieve frequent and fast releases.
Ensure the alignment between the requirement of the business context and application
development.
ip
• Rapid delivery must not be isolated to the software development process alone.
• The flow should go with the overall software development cycle.
• Experimental results must be continuously linked with the software roadmap.
.a
w
w
w
l
Download PDF
lo
1) Mention what is Jenkins?
Jenkins is an open source tool with plugin built for continuous integration purpose. The
principle functionality of Jenkins is to keep a track of version control system and to initiate and
x.
monitor a build system if changes occur. It monitors the whole process and provides reports and
notifications to alert.
le
In software development, when multiple developers or teams are working on different segments
of same web application, we need to perform integration test by integrating all modules. In order
to do that an automated process for each piece of code is performed on daily bases so that all
ip
your code get tested.
5) Explain how you can move or copy Jenkins from one server to another?
• Slide a job from one installation of Jenkins to another by copying the related job directory
• Make a copy of an already existing job by making clone of a job directory by a different name
• Renaming an existing job by renaming a directory.
x.
To start Jenkins manually, you can use either of the following
le
(Jenkin_url)/safeRestart: Allows all running builds to complete
• Stop Jenkins
w
Jenkins saves all the setting, build artifacts and logs in its home directory, to create a back-up of
your Jenkins setup, just copy this directory. You can also copy a job directory to clone or
replicate a job or rename the directory.
To clone a Git repository via Jenkins, you have to enter the e-mail and user name for your
Jenkins system. For that, you have to switch into your job directory and execute the “git config”
command.
l
To create a project that is handled via jobs in Jenkins. Select New item from the menu, once this
lo
done enter a name for the job and select free-style job. Then click OK to create new job in
Jenkins. The next page enables you to configure your job.
12) Mention what are the two components Jenkins is mainly integrated with?
x.
Jenkin is mainly integrated with two components
le
ip
.a
w
w
w