2CONFIDENTIAL
• Lead Software Engeneer at EPAM Systems Hungary
– 14 years experience, 5 years @ EPAM
• Software development
– Backend-side Java development
– Demonstrated history of working in the information technology and services industry
• Resource development
– EPAM Java Academy / Java EE trainer ~1.000 Man-Hours
– EPAM Java Mentor Program / Mentor, mentor-supervisor
About me
3CONFIDENTIAL
• Introduction
• What is Continuous Integration?
• Source code management (Git)
• Build automation (Maven)
• Repository management (Nexus)
• The CI server (Jenkins)
• Live demo
Agenda
4CONFIDENTIAL
INTRODUCTION
5CONFIDENTIAL
„It works on my machine!”
6CONFIDENTIAL
1. Requirements reviewed by team & approved by the customer
2. Code completed and checked into Git
3. Code coverage 100%
4. All unit & integration tests passed
5. Static code analisys performed
6. Code reviewed, review comments fixed
7. Code merged to develop branch
8. Demo performed
9. QA passed & all issues resolved
10. UAT passed & all issues resolved
Definition of Done
7CONFIDENTIAL
WHAT IS CONTINUOUS INTEGRATION?
8CONFIDENTIAL
Continuous Integration is a software development practice where members of a team integrate their
work frequently, usually each person integrates at least daily - leading to multiple integrations per
day. Each integration is verified by an automated build (including test) to detect integration errors
as quickly as possible. Many teams find that this approach leads to significantly reduced integration
problems and allows a team to develop cohesive software more rapidly.
Martin Fowler
What is Continuous Integration?
9CONFIDENTIAL
CI and Agile
Agile mindset
Agile framework
Agile techniques
Continuous Integration
Scrum, XP, Kanban,
etc.
„philosophy”
CI, Pair
Programming, etc.
Tools & conventions
10CONFIDENTIAL
Maintain common code repository
Frequent integration with mainline
Automated, fast build
Automated unit-testing as part of build
Dev, Test environments as clone of production
CI Principles
11CONFIDENTIAL
1. Reduced risk
2. Better communication
3. Faster iterations
4. Faster feedback
Results
13CONFIDENTIAL
Version Control System (Git, SVN, CVS, Mercurial)
VCS Manager (Gitlab)
Software Project Management (Maven, Ant, Gradle)
CI Servers (Jenkins, TeamCity, Bamboo)
Repository Management (Nexus, Artifactory)
Code Review, Documentation, Issue Tracking
CI Stack components & tools
14CONFIDENTIAL
Continuous Integration General idea of frequent integration, automated unit tests, build automation,
etc.
Continuous Delivery Product in mainline is always ready to be shipped to UAT/QA
Continuous deployment to UAT
Batched deployment to PROD
Continuous Deployment Automated deployment to PROD
Might not be in line with company policy
Continuous Delivery & Deployment
15CONFIDENTIAL
Maven in Real Projects
SOURCE CODE MANAGEMENT (GIT)
16CONFIDENTIAL
Why Git?
17CONFIDENTIAL
Non-linear development
Rapid branching, merging
Distributed environment
Efficient handling of large projects
Git Characteristics
18CONFIDENTIAL
GitHub flow
master feature/#12release
release
hotfix
19CONFIDENTIAL
Maven in Real Projects
BUILD AUTOMATION (MAVEN)
20CONFIDENTIAL
“Maven is a project management tool which encompasses a project object model, a set
of standards, a project lifecycle, a dependency management system, and logic for
executing plugin goals at defined phases in a lifecycle. When you use Maven, you
describe your project using a well-defined project object model, Maven can then apply
cross-cutting logic from a set of shared (or custom) plugins.”
From http://maven.apache.org/
What is Maven?
21CONFIDENTIAL
Convention Over Configuration
22CONFIDENTIAL
Declarative vs. Imperative
Initial state Results
Program explicitly
specifies process
Initial state Results
Program specifies
desired final state
What to do?
What we would
like to have as the
result?
23CONFIDENTIAL
• How do you run unit tests?
• What does the project need to build?
• What libraries do I need to download?
• Which quality gates we have?
• ...
Common Interface
mvn install
24CONFIDENTIAL
• Delegate most responsibility to a set of Maven Plugins
Maven Plugins
Core plugins
clean
compiler
deploy
failsafe
install
resources
site
surefire
verifier
Compiler plugin
goals
compile
help
testCompile
25CONFIDENTIAL
• Description of a software project
• Attributes of the project
• Project coordinates
• Enables features such as:
– Dependency management
– Remote repositories
– Universal reuse of build logic
– Tool Portability / Integration
– Easy Searching and Filtering
Conceptual Model of a "Project"
<project><modelVersion>4.0.0</modelVersion><groupId>com.epam.app</groupId><artifactId>best-app</artifactId><version>1</version>
</project>
26CONFIDENTIAL
Default lifecycle
validate initialize
generate-
sources
process-sources
generate-
resources
process-
resources
compile
process-classes
generate-test-
resources
process-test-
sources
generate-test-
resources
process-test-
resources
test-compile
process-test-
classes
test
prepare-package
package
pre-integration-
test
integration-test
post-integration-
test
verify
install
deploy
27CONFIDENTIAL
Create a simple Java project with maven
mvn archetype:generate-DgroupId=com.epam.training-DartifactId=first-project-DarchetypeArtifactId=maven-archetype-quickstart
first-project|-pom.xml|-src|---main|-----java|-------com|---------epam|-----------training|-------------App.java|---test|-----java|-------com|---------epam|-----------training|-------------AppTest.java
28CONFIDENTIAL
Triggering „install” phase will instruct Maven to place built artifact into Local repository.
Install project to local repo
mvn clean install
Internal network
Local machine
WorkspaceLocal
repository
Remote
repositoryCentral
repository
29CONFIDENTIAL
• Add your artifact to a remote repository for
sharing with other developers and projects
Deploy project
Internal network
Local
repository
Local
repository
Remote
repository
Central
repository
mvn clean deploy
30CONFIDENTIAL
• Transitive Dependencies
• Dependency mediation
• Excluded dependencies
• Optional dependencies
• Dependency scope
Dependency resolution
<project> ...<dependencies>
<dependency><groupId>test</groupId><artifactId>runner</artifactId><version>1.0</version><scope>runtime</scope>
</dependency></dependencies>...
</project>
31CONFIDENTIAL
Multi-module projects
<project> <modules><module>calculator-lib</module><module>calculator-app</module>
</modules>[...]
</project>
calculator
calculator-
app
calculator-
lib
• Typical in real-life projects
32CONFIDENTIAL
• Configuration reuse
• pom -> parent-pom -> super-pom
• Effective pom
Configuration inheritance
<project><groupId>com.epam.sampleproject</groupId><artifactId>sample-parent</artifactId><version>0.0.1-SNAPSHOT</version>
</project>
<project><parent>
<groupId>com.epam.sampleproject</groupId><artifactId>sample-parent</artifactId><version>0.0.1-SNAPSHOT</version>
</parent></project>
33CONFIDENTIAL
IDE independence
POM
34CONFIDENTIAL
Maven in Real Projects
REPOSITORY MANAGEMENT (NEXUS)
35CONFIDENTIAL
A repository manager is a dedicated server application designed to manage repositories of binary
components. The usage of a repository manager is considered an essential best practice for any
significant usage of Maven.
Nexus
36CONFIDENTIAL
• „deploy” instructs Maven do deploy artifact(s) to remote repository defined in distribution
management
Deployment to remote repository
mvn clean deployLocal
repository
Remote
repository
<distributionManagement><repository><id>training-releases</id><url>http://192.168.33.20:8081/nexus/content/repositories/releases/</url>
</repository><snapshotRepository><id>training-snapshots</id><url>http://192.168.33.20:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository></distributionManagement>
37CONFIDENTIAL
Snapshots
• Repository Policy: Snapshot
• Deployment Policy: Allow redeploy
Releases
• Repository Policy: Release
• Deployment Policy: Disable redeploy
Nexus hosted repositories
38CONFIDENTIAL
Maven in Real Projects
CI SERVER (JENKIINS)
39CONFIDENTIAL
Jenkins is an award-winning, cross-platform, continuous integration and continuous delivery
application that increases your productivity. Use Jenkins 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 providing
powerful ways to define your build pipelines and integrating with a large number of testing and
deployment technologies.
Jenkins
40CONFIDENTIAL
• Free
• Core distribution
• Lots of public plugins
• Extensibility - team can develop their own plugins with Jenkins API
• Scalability – multiple slaves (agents)
Jenkins features
41CONFIDENTIAL
Jenkins UI
42CONFIDENTIAL
Jenkins Agent
• How does it work?
Jenkins - Junior Program CI – Build
Git Repo workspaceLocal
repository
Git fetchRemote
Nexus
mvn clean install mvn clean deploy
43CONFIDENTIAL
Main sections:
• Header (Maven project name, Project description, etc.)
• Source Code Management (Git, URL, credentials, Branch Specifier – master)
• Build trigger (Poll scm – Cron trigger or triggered by the VCS server)
• Build commands
– mvn clean deploy
– Publish results (JUNit, Checkstyle, FindBugs, Cobertura, etc.)
– Deploy to container
– Etc.
Configure Jenkins Job
44CONFIDENTIAL
Maven in Real Projects
LIVE DEMO
45CONFIDENTIAL
Maven in Real Projects
THANK YOU!