Continuous Integration is a software development practice where developers regularly merge their work into a central repository. When code is committed, an automated build is triggered to check that new code does not break the existing code base. There are typically five stages of adopting Continuous Integration: 1) a few manual commits and builds, 2) nightly automated builds, 3) builds triggered with every commit, 4) code quality metrics added to builds, 5) automated deployment to staging environments. Continuous Integration helps catch bugs early in the development process and ensures code quality.
2. Continuous Integration
• What is Continuous Integration?
• Why do we need it?
• Different phases of adopting Continuous Integration
3. • Developers commit code to a shared
repository on a regular basis.
• Version control system is being monitored.
When a commit is detected, a build will be
triggered automatically.
• If the build is not green, developers will be
notified immediately.
What is Continuous Integration?
4. Why do we need Continuous Integration?
• Detect problems or bugs, as early as possible, in the
development life cycle.
• Since the entire code base is integrated, built and tested
constantly , the potential bugs and errors are caught earlier in
the life cycle which results in better quality software.
6. Few commits
Stage 1:
• No build servers.
• Developers commit
on a regular basis.
• Changes are integrated and
tested manually.
• Fewer releases.
7. Stage 2:
Build nightly
Build and run tests
• Automated builds are
scheduled on a regular basis.
• Build script compiles the
application and runs a set of
automated tests.
• Developers now commit their
changes regularly.
• Build servers would alert the
team members in case of
build failure.
8. Stage 3:
Triggered
atomically
Build and run tests
• A build is triggered whenever
new code is committed to
the central repository.
• Broken builds are usually
treated as a high priority
issue and are fixed quickly.
9. Stage 4:
Triggered
atomically
Build, run code quality and code
coverage metrics along with tests
• Automated code quality
and code coverage metrics
are now run along with
unit tests to continuously
evaluate the code quality.
Is the code coverage increasing?
Do we have fewer and fewer
build failures?
14. • Continuous Integration
The practice of merging development work with the main branch
constantly.
• Continuous Delivery
Continual delivery of code to an environment once the code is ready to
ship. This could be staging or production. The idea is the product is
delivered to a user base, which can be QAs or customers for review and
inspection.
• Continuous Deployment
The deployment or release of code to production as soon as it is ready.
16. How to implement Continuous Integration?
Non-hosted solutions Hosted solutions
17. Continuous Integration is also a mindset
• Fixing broken builds should be treated as a high priority issue for all team
members.
• The deployment process should be automated, with no manual steps involved.
• All team members should focus on contributing to high-quality tests because the
confidentiality of the CI process highly depends on the quality of the tests.
18. What is Jenkins
• Jenkins is a continuous integration and build server.
• It is used to manually, periodically, or automatically build software
development projects.
• It is an open source Continuous Integration tool written in Java.
• Jenkins is used by teams of all different sizes, for projects with various
languages.
19. Why Jenkins is popular
• Easy to use
• Great extensibility
– Support different version control systems
– Code quality metrics
– Build notifiers
– UI customization
22. • Jenkins’ Master and Slave Architecture
• Some Important Jenkins’ Terminologies
23. Jenkins’ Master and Slave Architecture
Master:
• Schedule build jobs.
• Dispatch builds to the slaves for the
actual job execution.
• Monitor the slaves and record the
build results.
• Can also execute build jobs directly.
Slave:
• Execute build jobs dispatched by
the master.
32. Maven pom.xml file
• Describe the software project being built, including
– The dependencies on other external modules.
– The directory structures.
– The required plugins.
– The predefined targets for performing certain tasks such as
compilation and packaging.
33. Different Phases in Maven Build Lifecycle
validate Validate the project is correct and all necessary information is available.
compile Compile the source code of the project.
test Test the compiled source code using a suitable unit testing framework.
package Take the compiled code and package it in its distributable format.
verify Run any checks on results of integration tests to ensure quality criteria are met.
install Install the package into the local repository, for use as a dependency in other
projects locally.
deploy Copy the final package to the remote repository for sharing with other
developers and projects.
34. Maven Build Phases
• These lifecycle phases are executed sequentially to complete the default
lifecycle.
• We want to specify the maven package command, this command would
execute each default life cycle phase in order including validate, compile,
test before executing package.
• We only need to call the last build phase to be executed.
36. Checkstyle is a code static analysis tool to help programmers to write
Java code that adheres to a coding standard such as
• Avoiding multiple blank lines;
• Removing unused variables;
• Enforcing correct indentations;
• …
40. Apache Ant
• Widely-used and very well-known build scripting language for Java.
• Flexible, extensible, relatively low-level scripting language.
• An Ant build script is made up of a number of targets, each target
performs a particular job in the build process.
41. Gradle
• Gradle is a relatively new open source build tool for the Java Virtual Machine.
• Build scripts for Gradle are written in a Domain Specific Language based on
Groovy.
• The concise nature of Groovy scripting lets you write very expressive build scripts
with very little code.
53. Additional automation
• Setup Git repository polling
• Deployment to our tomcat servers
• We will setup tasks to run in parallel
54. Steps
• Step 1: Configure securit groups for Tomcat servers and create key pairs.
• Step 2: Provision instances to staging and production
environments.
• Step 3: Install and run Tomcat on created instances.
• Step 4: Fully automate our existing Jenkins pipeline.
60. Build Orchestration: Jenkins
_____________________________
• Continuous integration system
• Enable automated build and test process
• Can monitoring executions of externally‐run jobs, such as cron
jobs and procmail jobs…
• Dependency tracking, allowing file finger printing and tracking
for example which build is using which version of jars…
• Generates list of changes made to build from Subversion
• Distributed build/test
• Jenkins is a build orchestration, CI software
• building/testing software projects continuously
• monitoring executions of externally‐run jobs
• FishEye allows you to extract information from your source
code repository and display it in sophisticated reports.
• Crucible allows you to request, perform and manage code
reviews.
• Subversion centralized version control system
• Sonar is a quality management platform for analyzing and
measuring source code quality.
61. CI/CD Pipeline: Functional Architecture
_______________________________________________
Version Control
Version
Control
System
Code
Repository
Artifact
Repository
(Artifactory)
Build
Management
(Maven)
Build
Automation
(Jenkins)
Test
Automation
QA
(SonarCube)
Release
Orchestration
Deployment
Automation
Develop
Pre-commit
Tests
1
2
Commit code to
Version Control
System
3 CI polls VCS
and creates Build
5
Automated Test
Staging
UAT SAT
Security Scan
Perf. & Load Testing
7
4
6
Release
8
Fail
Fail
Fail
Not approved
9
62. An Automated, Integrated and End to Ent CCRM
_______________________________________________
Git, GitLab, GitHub Enteprise,
SVN…
Maven, Ant, Gradle
Nexsus, Artifactory
Jenkins…
Junit, Test NG, Cucumber, Selenium, JMeter, SoapUI, LoadRunner…
Release
Management
Source Code
Management
(Version Control)
Build
Automation
CCRM
Test
Automation
Environment
Configuration
Management
CI/CD