Training - Introduction to DevOps and CI/CD

Last Updated on: August 17, 2021 pm

Maven

pom.xml

Defines project object model.

Example:

1
2
3
4
<groupId>com.conygre.rest.test</groupId> 
<artifactId>RESTBasicExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

Note: packaging

  • Is it a WAR, JAR, EAR, or POM?
  • How should the app be built

Dependency Management

  • Download them from a remote repository (typically online) and then place them in a local repository on your system
  • The local repository is <USER_HOME_DIR>\.m2

Build Steps

  • compile - Compile the code
  • test - Run the tests
  • package - Package up the app (JAR, WAR, EAR)
  • install - Place package into local repository
  • deploy - Place in remote repository and increment version

Basically, we use mvn clean package to delete previous build package app.

To run the project in terminal, type java -jar NAMEOFJAR after compilation.

Setting Up Maven - Mac

  • Run brew install maven in terminal.
  • Run mvn --version to check installation.
1
2
3
4
5
6
(base) xinyima@Xinyis-MacBook-Pro ~ % mvn --v
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /opt/homebrew/Cellar/maven/3.8.2/libexec
Java version: 16.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
Default locale: en_CA, platform encoding: UTF-8
OS name: "mac os x", version: "11.2", arch: "x86_64", family: "mac"

Note:

  1. Maven Home - /opt/homebrew/Cellar/maven/3.8.2/libexec
  2. JAVA Home - /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
  3. settings.xml Path - /opt/homebrew/Cellar/maven/3.8.2/libexec/conf/settings.xml
  4. .m2 Folder Path - /Users/xinyima/.m2
  5. Maven Version - Apache Maven 3.8.2

Introduction to DevOps and CI/CD

Reference

What is DevOps

Bring developers and operations closer together to take responsibility for building, deploying and monitoring application

Continuous Integration

Members of a team integrate their work frequently, usually each person integrates at least daily – leading to multiple integrations per day.

Continuous Delivery

The essence is to make sure that the software is always in a state where it could be put into production.

Continuous Delivery = Continuous Integration + Fully automated test suite

Continuous Deployment

An Automated process that goes to production env.

Diff

Pipeline

This is the process that code changes go through before they are ready to be delivered to production.

Process

Code -> Build -> Automated all tests -> Deploy (to Artifactory)

Deployment Strategies

Rolling Deployment

Update Servers one by one - in-place update

Rollback when getting wrong.

Blue-green Deployment

2 Envs.
Install on one of them, then switch.

Canary Release

Jenkins

Jenkins Pipeline

Check in the pipeline file in Git along with the project.

Any Jenkins server can then complete the build - even one just launched from a container. - with Jenkinsfile

Jenkins can also run in a Docker container.