In Demo session we have Overview the all CI/CD tools
- Overview about the all CI/CD & AWSDevOps Training flow
- Discussed about the all the DevOps roles
DevOps is a software development and operations (DevOps) methodology that combines these two to improve efficiency and speed up project deliverables, It's very important because it helps businesses/deliver software faster and with higher quality.
What is the key purpose of DevOps? The primary goal of DevOps is to bridge the gap between development and operations teams. It creates a streamlined, efficient workflow that delivers software faster and with higher quality. DevOps is a set of practices,tools that automate and integrate the processes between software development and IT teams.
1)The devops engineer was responsibility to release the product to the market as soon as possible 2) release the product speed to the market 3)Devops engineer was give continues feedback to the developers 4) Devops engineer responsibility start from git and end with production
• Faster software delivery: Reduces lead times and speeds up the software delivery process • Higher software quality: Addresses bugs quicker and improves software quality • Better collaboration: Unifies development and operations teams, enhancing collaboration and efficiency • Competitive advantage: Creates a more nimble software development lifecycle that gives businesses an advantage over their competitors
What is Git?
Git is a free, open-source version control system (VCS) that helps developers manage their code. It's the most widely used tool VCS(version control system) Git is fast for committing, branching, merging, and comparing past versions Git is very high Performance and Flexibility,Security.
https://git-scm.com/downloads/win
Please download the ---64-bit Git for Windows Setup.
Once download the git .exe file , double click and install the git on your machine
once installed right click on your local machine you can found Open Git batch here option, means git is installed successfully in your machine.
For creating github account EmailId is Required
go to link --https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F&source=header-home
Enter Email & password ,Username click continue ---Account will create successfully image
Github::Github is a one of the SCM(Source code management) tool and store the Project code.
Repository: storage area of your source code. Create a Repository on GitHub
click Repositories
Click New
Enter Repository Name::SRINFOTECHDEMO
Public:: Anyone on the internet can see this repository.
Private:: You choose who can see and commit to this repository.
select Add a README file
Click Create Repository
Repository Created SUccessfully with Default branch main
GitHub is a web-based platform for version control and collaboration, allowing developers to store and manage their code in repositories.
Version Control: :: GitHub uses Git, a distributed version control system, to track changes in code. This allows multiple people to work on the same project without overwriting each other's contributions.
Repositories::: where you can store your project files and track the history of changes made to those files.Public and private repos can be created depending on accessibility needs.
git and github communication happend via SSH keys
open gitbash and run the below command
syntax::ssh-keygen -t ed25519 -C "your_email@example.com"
ssh-keygen -t ed25519 -C "srinfotechbatch2@gmail.com"
HP@DESKTOP-E518Q66 MINGW64 ~ $ ssh-keygen -t ed25519 -C "srinfotechbatch2@gmail.com" Generating public/private ed25519 key pair. Enter file in which to save the key (/c/Users/HP/.ssh/id_ed25519): /c/Users/HP/.ssh/id_ed25519 already exists. Overwrite (y/n)? y Enter passphrase for "/c/Users/HP/.ssh/id_ed25519" (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/HP/.ssh/id_ed25519 Your public key has been saved in /c/Users/HP/.ssh/id_ed25519.pub The key fingerprint is: SHA256:CqROf7Z/FpbjGWy8/vMYGCS6Uq1ttFi/dKY2iAuBprg srinfotechbatch2@gmail.com The key's randomart image is: +--[ED25519 256]--+ | | | | | . . . | | + o o | | = o o So.. | |.= . + O oXo | |o . + B.+=+*+ | | . =.o..O=.o | |E oo.=+ooo. | +----[SHA256]-----+
https://docs.github.com/en/authentication/connecting-to-github-with-ssh
steps::
Your public key has been saved in /c/Users/HP/.ssh/id_ed25519.pub
right click and open id_ed25519.pub, and copy public key to Github Account
Go to -->Your Copilot OR settings, click your copilot
Click SSH and GPG Keys
click New SSH Key
Add new SSH Key and click Add SSH Key
ssh public key is added in github account
Fork means to make a copy of the repository into my own github account A fork is a copy of a repository
first we need to create the repository
Go to Repositories
Click New
Enter Repository Name
select public
select Readmefile.md
Click Create Repository
Empty repository Created
1.git clone git@github.com:srinfotechbatch2/SRINfotechDemo.git
2.cd SRINfotechDemo
3.git status
4.git add --all
5.git status
6.git commit -m "i have added hellow world project files"
7.git push ---->from local changes pushed to remote
8.git pull --->remote to local
above steps to push some changes from Local to remote repository
Go to Repositories
Click Branch
Click New Branch
New feature Branch Formate----> feature/YYYY.MM.DD
feature/2025.06.22
Branch Created Successfully
once branch created in github , we need to pull the new branch from Remote to Local
git pull
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git pull From github.com:srinfotechbatch2/SRINfotechDemo
- [new branch] feature/2025.06.22 -> origin/feature/2025.06.22 Already up to date.
Switch one branch to another branch using git checkout command
git checkout
git checkout feature/2025.06.22
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git checkout feature/2025.06.22 branch 'feature/2025.06.22' set up to track 'origin/feature/2025.06.22'. Switched to a new branch 'feature/2025.06.22'
please make some changes in source code like Jenkinsfile and try to push changes to github repository, please follow below steps
1.git status
2.git add --all
3.git status
4.git commit -m "i have added hellow world project files"
5.git push
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps $ git clone git@github.com:srinfotechbatch2/SRINfotechDemo.git Cloning into 'SRINfotechDemo'... The authenticity of host 'github.com (20.207.73.82)' can't be established. ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) Receiving objects: 100% (3/3), done.
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps $ cd SRINfotechDemo/
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git status On branch main Your branch is up to date with 'origin/main'.
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: README.md
Untracked files: (use "git add ..." to include in what will be committed) .gitignore .whitesource Jenkinsfile pom.xml src/
no changes added to commit (use "git add" and/or "git commit -a")
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git add --all warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of '.whitesource', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'Jenkinsfile', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'pom.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'src/main/java/hello/Greeter.java', LF will be replaced by CRLF the next time G it touches it warning: in the working copy of 'src/main/java/hello/HelloWorld.java', LF will be replaced by CRLF the next tim e Git touches it
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git status On branch main Your branch is up to date with 'origin/main'.
Changes to be committed: (use "git restore --staged ..." to unstage) new file: .gitignore new file: .whitesource new file: Jenkinsfile modified: README.md new file: pom.xml new file: src/main/java/hello/Greeter.java new file: src/main/java/hello/HelloWorld.java
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git commit -m "i have added hello world project files" [main 2f04570] i have added hello world project files 7 files changed, 367 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 .whitesource create mode 100644 Jenkinsfile create mode 100644 pom.xml create mode 100644 src/main/java/hello/Greeter.java create mode 100644 src/main/java/hello/HelloWorld.java
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git push Enumerating objects: 15, done. Counting objects: 100% (15/15), done. Delta compression using up to 4 threads Compressing objects: 100% (10/10), done. Writing objects: 100% (13/13), 5.42 KiB | 793.00 KiB/s, done. Total 13 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) To github.com:srinfotechbatch2/SRINfotechDemo.git 03b032f..2f04570 main -> main
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git pull From github.com:srinfotechbatch2/SRINfotechDemo
- [new branch] feature/2025.06.22 -> origin/feature/2025.06.22 Already up to date.
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (main) $ git checkout feature/2025.06.22 branch 'feature/2025.06.22' set up to track 'origin/feature/2025.06.22'. Switched to a new branch 'feature/2025.06.22'
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git status On branch feature/2025.06.22 Your branch is up to date with 'origin/feature/2025.06.22'.
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: Jenkinsfile
no changes added to commit (use "git add" and/or "git commit -a")
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git add --all warning: in the working copy of 'Jenkinsfile', LF will be replaced by CRLF the next time Git touches it
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git commit -m "modified jenkinsfile" [feature/2025.06.22 9bb0cbe] modified jenkinsfile 1 file changed, 13 deletions(-)
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git push Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 4 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 290 bytes | 145.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To github.com:srinfotechbatch2/SRINfotechDemo.git 2f04570..9bb0cbe feature/2025.06.22 -> feature/2025.06.22
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git status On branch feature/2025.06.22 Your branch is up to date with 'origin/feature/2025.06.22'.
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: Jenkinsfile
no changes added to commit (use "git add" and/or "git commit -a")
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git add --all warning: in the working copy of 'Jenkinsfile', LF will be replaced by CRLF the next time Git touches it
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git commit -m "modified jenkinsfile" [feature/2025.06.22 aff43d0] modified jenkinsfile 1 file changed, 13 insertions(+)
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git push Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 4 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 527 bytes | 263.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) remote: Resolving deltas: 100% (1/1), completed with 1 local object. To github.com:srinfotechbatch2/SRINfotechDemo.git 9bb0cbe..aff43d0 feature/2025.06.22 -> feature/2025.06.22
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git status On branch feature/2025.06.22 Your branch is up to date with 'origin/feature/2025.06.22'.
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: Jenkinsfile
no changes added to commit (use "git add" and/or "git commit -a")
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git add --all warning: in the working copy of 'Jenkinsfile', LF will be replaced by CRLF the next time Git touches it
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git status On branch feature/2025.06.22 Your branch is up to date with 'origin/feature/2025.06.22'.
Changes to be committed: (use "git restore --staged ..." to unstage) modified: Jenkinsfile
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git commit -m "modified jenkinsfile" [feature/2025.06.22 41147f7] modified jenkinsfile 1 file changed, 1 insertion(+), 12 deletions(-)
HP@DESKTOP-E518Q66 MINGW64 ~/OneDrive/Documents/SR InfoTech/AWS DevOps/SRINfotechDemo (feature/2025.06.22) $ git push Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 4 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 291 bytes | 291.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To github.com:srinfotechbatch2/SRINfotechDemo.git aff43d0..41147f7 feature/2025.06.22 -> feature/2025.06.22
A GitHub branching model is a structured way of organizing branches in a Git repository to manage development workflows effectively. It helps teams work collaboratively, isolate features, manage releases, and deploy code more efficiently.
https://github.com/srinfotechbatch2/SRINfotechDemo
main (or master): Always production-ready.
feature/*: Used for new features.
release/*: Prepares for a new production release.
main or master branch:: This is default branch and whenever we created the empty Repository by defauly main or master branche is created automatically. main or master branch always stable and live code
feature branch:: It could be a new feature, an improvement of existing features, bug fixes, or any other changes. A feature branch is a type of branch in Git typically used to develop new features for the software.feature branch will created from main or master OR feature branch created from latest release branch always based on the release cycle
formate:: feature/YYYY.MM.DD feature/2025.06.22
release branch:: Based on the release we have created release branch accourdingly and starts the next release cycle. always release branch created from master only and master have stable and live code and post release we shold merged code changes to master branch only
release/2025.07.20
hotfix branch:: always created from main or master branch only for production fixes.once production fix done we should merged directly to main or master branch only.
always created this hotfix branch for production issues fixes
bugfix:: this branch is created from release branch to fix the LLE(lower level environemnt)/Pre-Prod/UAT/Non-Prod issues and once LLE issues fixed ,we should pushed their changes to release branch only.
Merge the code from one branch to another branch that is called pull request
below are the steps to raise PR::
Go to -->Pull requests and click
Click New Pull Request::
Compare & pull Request
select base & compare options
Raise PR(Pull Request) from feature to release branch
please select base & compare branches so here base branch is release/2025.06.29 and compare branch is feature/2025.06.22
i'm going to merge code changes from feature branch to release branch
click create pull request
click merge request
confirm merge
merged 1 commit into release/2025.06.29 from feature/2025.06.22 Copied!
If multiple developers OR DevOps Engineers are working on same Project/MOdules, if they tried to commits thier code changes to Repository, it will faces the conflicts issues and how to resolved those conflicts issues in real time projects
git pull --->git pull command is use, copies changes from a remote repository directly into your working directory (local directory) and merged code changes from remote repository to local repository git fetch ---->The git fetch command only fetch the changes into your local Git repo and it will not merged anything. just fetch the details
Please create developer1,developer2,developer3 directories in your local machine and clone the project code separately
Editor steps for Resolved the conflicts::
resolved conflicts::
git pull
opend the editor
1.presh the i from your keyboard
2.esc
3.swift+:
4.wq
5.enter
git checkout feature/2025.02.27 error: pathspec 'feature/2025.02.27' did not match any file(s) known to git
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/A/spring-petclinic (main) $ git pull From github.com:parasa7358/spring-petclinic
- [new branch] feature/2025.02.27 -> origin/feature/2025.02.27 Already up to date.
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/A/spring-petclinic (main) $ git checkout feature/2025.02.27 branch 'feature/2025.02.27' set up to track 'origin/feature/2025.02.27'. Switched to a new branch 'feature/2025.02.27'
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/A/spring-petclinic (feature/2025.02.27) $ git status On branch feature/2025.02.27 Your branch is up to date with 'origin/feature/2025.02.27'.
Untracked files: (use "git add ..." to include in what will be committed) Jenkinsfile
nothing added to commit but untracked files present (use "git add" to track)
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/A/spring-petclinic (feature/2025.02.27) $ git add --all warning: in the working copy of 'Jenkinsfile', LF will be replaced by CRLF the next time Git touches it
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/A/spring-petclinic (feature/2025.02.27) $ git status On branch feature/2025.02.27 Your branch is up to date with 'origin/feature/2025.02.27'.
Changes to be committed: (use "git restore --staged ..." to unstage) new file: Jenkinsfile
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/A/spring-petclinic (feature/2025.02.27) $ git commit -m "Added jenkins file for Feb Release" [feature/2025.02.27 9ad4ee0] Added jenkins file for Feb Release 1 file changed, 22 insertions(+) create mode 100644 Jenkinsfile
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/A/spring-petclinic (feature/2025.02.27) $ git push Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 4 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 483 bytes | 241.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) remote: Resolving deltas: 100% (1/1), completed with 1 local object. To github.com:parasa7358/spring-petclinic.git e4b9aa2..9ad4ee0 feature/2025.02.27 -> feature/2025.02.27
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/B/spring-petclinic (feature/2025.02.27) $ git pull Already up to date.
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/B/spring-petclinic (feature/2025.02.27) $ git status On branch feature/2025.02.27 Your branch is ahead of 'origin/feature/2025.02.27' by 2 commits. (use "git push" to publish your local commits)
nothing to commit, working tree clean
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/B/spring-petclinic (feature/2025.02.27) $ git push Enumerating objects: 9, done. Counting objects: 100% (8/8), done. Delta compression using up to 4 threads Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 586 bytes | 293.00 KiB/s, done. Total 5 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0) remote: Resolving deltas: 100% (3/3), completed with 2 local objects. To github.com:parasa7358/spring-petclinic.git 9ad4ee0..ed57c5e feature/2025.02.27 -> feature/2025.02.27
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/C/spring-petclinic (feature/2025.02.27) $ git status On branch feature/2025.02.27 Your branch is ahead of 'origin/feature/2025.02.27' by 2 commits. (use "git push" to publish your local commits)
nothing to commit, working tree clean
HP@DESKTOP-E518Q66 MINGW64 ~/Desktop/C/spring-petclinic (feature/2025.02.27) $ git push Enumerating objects: 33, done. Counting objects: 100% (24/24), done. Delta compression using up to 4 threads Compressing objects: 100% (9/9), done. Writing objects: 100% (13/13), 1.14 KiB | 233.00 KiB/s, done. Total 13 (delta 5), reused 0 (delta 0), pack-reused 0 (from 0) remote: Resolving deltas: 100% (5/5), completed with 5 local objects. To github.com:parasa7358/spring-petclinic.git ed57c5e..80681f1 feature
Please be practice above 3 developers activity in real time bases
git fetch--->just fetch
git pull -->fetch+merged
1.git clone git@github.com:srinfotechbatch2/SRINfotechDemo.git
2.cd SRINfotechDemo
3.git status
4.git add --all
5.git status
6.git commit -m "i have added hellow world project files"
7.git push ---->from local changes pushed to remote
8.git pull --->remote to local
9.git checkout
git checkout feature/2025.06.22
10.git pull --->every devlioper beforre pushing their changes we should make sure git pull the every time
clone Clone a repository into a new directory
add Add files
status Show the working tree status
commit Record changes to the repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
1.install git 2.introcuction about git-->VCS 3.github-->SCM 4.introduction about github 5.github account 6.create repositories 7.integarte git & github via SSH keys--->ssh-keygen -t ed25519 8.how to created branch in github 9.how to rasie PR-->pull requests--->feature branch to release 10. git commands::
1.git clone 2.cd 3.git checkout 4.git status 5.git add -all 6.git commit 7.git push 8.git pull 9.git fetch 10.
git pull
opend the editor
1.presh the i from your keyboard 2.esc 3.swift+: 4.wq 5.enter
10.how to resolved the git conflicts 11.github branching model/stargety 12.end to end flow of git & github
Jenkins is a free and open source automation server/tool. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.
Jenkins is a Orchestration tool
Jenkins is a CI/CD tool
Jenkins is a Schedular
Jenkins is a crone job schedular
1)The devops engineer was responsibility to release the product to the market as soon as possible 2)release the product speed to the market 3)Devops engineer was give continues feedback to the developers 4) Devops engineer responsibility start from git and end with production
A) when your activity start from git and end with production environment(production servers)Continues deployment when your activity start from git to LLE(lower level environment,testing environment,pre-prod…et) environment(pre-production servers)Continues delivery non-production environment
Tutorials::
https://www.tutorialspoint.com/jenkins/jenkins_overview.htm https://www.geeksforgeeks.org/jenkins-tutorial/#prerequisites
Download JDK 17 ::
https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html
Windows x64 Installer 153.92 MB
Windows x64 Compressed Archive 172.87 MB https://download.oracle.com/java/17/archive/jdk-17.0.12_windows-x64_bin.zip (sha256 )
Go to Search box & type Edit the system environemnt variables and click
It will navigate to System properties
Click Environment Variables
Click New
Variable Name:: JAVA_HOME
Variable Value:: C:\Users\HP\Downloads\jdk-17.0.12_windows-x64_bin\jdk-17.0.12
Click OK
Edit Path
Click New and give Java Installed path till \bin
C:\Users\HP\Downloads\jdk-17.0.12_windows-x64_bin\jdk-17.0.12\bin
Click OK
You Can verify Java is Installed Or Not
Go to command Prompt
java --version
C:\Users\HP>java --version java 17.0.12 2024-07-16 LTS Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286) Java HotSpot(TM) 64-Bit Server VM (build 17.0.12+8-LTS-286, mixed mode, sharing)
Above Screeenshot JDK17 setup is done
https://www.jenkins.io/download/
Go to google search -->download jenkins war file for windows
click below Jenkins version
Download Jenkins 2.515 for:
Jenkins.war file is downloaded
Maven is a powerful build automation tool used primarily for Java projects. Developed by the Apache.
it helps developers manage a project's build, dependencies, documentation, and more—all using a single configuration file called pom.xml
-
mvn clean ------------> Deletes target/ directory (clean build).
-
mvn compile -----------> Compiles the source code.
-
mvn test ------------> Runs tests.
-
mvn package ------------> Creates a JAR/WAR.
-
mvn install ------------> Installs package into your local repository.
-
mvn deploy -------------> Deploys package to a remote repository.
Maven Download link
https://maven.apache.org/download.cgi
Please download below zip file
Binary zip archive apache-maven-3.9.10-bin.zip
Downloaded Zip file
Please extract the file
Go to Search box & type Edit the system environemnt variables and click
It will navigate to System properties
Click Environment Variables
Click New
Variable Name:: MAVEN_HOME
Variable Value:: C:\Users\HP\Downloads\apache-maven-3.9.10
Click OK
Edit Path

Click New and give maven Installed path till \bin
C:\Users\HP\Downloads\apache-maven-3.9.10\bin
Click OK
You Can verify maven is Installed Or Not
Go to command Prompt
mvn -v
C:\Users\HP>mvn -v
Apache Maven 3.9.10 (5f519b97e944483d878815739f519b2eade0a91d) Maven home: C:\Users\HP\Downloads\apache-maven-3.9.10 Java version: 17.0.12, vendor: Oracle Corporation, runtime: C:\Users\HP\Downloads\jdk-17.0.12_windows-x64_bin\jdk-17.0.12 Default locale: en_IN, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Above Screeenshot maven setup is done
Please follow the below link steps to installed jenkins in your windows machines
https://www.jenkins.io/doc/book/installing/war-file/
https://www.jenkins.io/download/
Go to google search -->download jenkins war file for windows
click below Jenkins version
Download Jenkins 2.515 for:
Jenkins.war file is downloaded
Steps::
https://www.jenkins.io/download/
- First download the jenkins.war file and right click -->open gitbash here
- run the command -->java -jar jenkins.war --httpPort=9090
we can see Jenkins is fully up and running
Browse to http://localhost:9090 and wait until the Unlock Jenkins page appears
Installed the default suggested plugins
click on continue
Need to create jenkins user profile
USER Name--->admin (any name you can provide)
PASSWORD -->admin (any password as your wish but make sure you should remembered the these credentials)
Steps::
1.first we need to create New repository in Github
2.please Clone the Empty Repositoy in your local system
3.copy the Spring-petclinic project code to in your repository
4.once done we need to push project code to github repository
- we need to integarte Github to Jenkins
we need to create Sample demo Project in Jenkins
Click New Item
Configuration stages::
1.General
2.Source code management (SCM)
3.Triggres
4.Environment
5.Build Steps
6.Post Build Actions
General Section provide the Project/job description
At SCM stage level select the Git and provide the github details
Below url is spring-petclinic Project and everyone Should please Fork to your github account
https://github.com/srinfotechbatch2/spring-petclinic
https://github.com/srinfotechbatch2/spring-petclinic.git
Branches to build
Build steps::select the Invoke top-level Maven targets Goals section
mvn clean install
Maven goals::
mvn test
mvn install
mvn clean install
mvn clean
mvn package
Job will be created
Click Build Now
Buils is Inprogress
Success Builds
Poll SCM ::Jenkins server ask git if there is any changes in git server or not, if changes there Jenkins server build/package the changes , every change build happened like 5 mints ,means every 5 minutes verify the Jenkins server to git if there is any changes
POLL SCM ----* * * * * --every minute when every commit
https://crontab.guru/examples.html
Go to jenkins Dashboard click New Item
Description
Provide the Git URL
https://github.com/srinfotechbatch2/onlinebookstore.git
Branch buiild
POLL SCM:: * * * * *
every minute build was trigger when new commits happend in github repository
Build Steps::
Select Invoke top-level Maven targets
Once New Commits Happend in Github , Automatically Build is triggered in The Jenkins Server this Called CI (Continuous Integration)
once build success we can bale to see the /target folder under the Workspace
1.To check a job's workspace:
2.Navigate to the job in the Jenkins UI.
3.Click on "Workspace" in the left sidebar.
Under Target Folder we can able to see the all .ear/war/jar/zip Artifacts Formates
PLease try to execute the Project with below Maven Goals and see the difference
https://github.com/srinfotechbatch2/onlinebookstore.git
https://github.com/srinfotechbatch2/spring-petclinic.git
-
mvn clean ------------> Deletes target/ directory (clean build).
-
mvn compile -----------> Compiles the source code.
-
mvn test ------------> Runs tests.
-
mvn package ------------> Creates a JAR/WAR.
-
mvn install ------------> Installs package into your local repository.
-
mvn deploy -------------> Deploys package to a remote repository.
Jenkins server ask git if there is any changes in git server or not, if changes there Jenkins server build/package the changes , every change build happened like 5 mints ,means every 5 minutes verify the Jenkins server to git if there is any changes
POLL SCM ----* * * * * --every minute when every commit
H/15 * * * * ----this build happened every 5 minutes without commits ,if changes are commit or not but every 5 mints build happened in Jenkins
Please create a New Jenkins jobs both POLL SCM & Build Periodically
https://github.com/srinfotechbatch2/spring-petclinic.git https://github.com/srinfotechbatch2/onlinebookstore.git
To automate the process of discarding old builds, you can configure the job’s settings to automatically delete old builds based on criteria such as the number of builds to keep or the age of the builds.
Follow these steps:
Open the Jenkins job (project). Click on Configure (on the left-hand side). Scroll down to the Build Discarder section (usually under the Build Triggers section). Check Discard old builds. Specify the following options: Max # of builds to keep: Set the maximum number of builds to keep. Max days to keep builds: Set the maximum age for builds to keep. Save the configuration by clicking Save.
1.By Default execute the Jenkins build jobs are sequence way,one by one
2.Don’t do 2 projects build parallel this is real time scenario but we can do parallel builds as well one job
Jenkins build parallel setup
Go job ---> configure ----> Generall ---> Execute concurrent builds if necessary
Here 5 builds execute parallel ,I kept executor is 5 this is same machine
Build Periodically::: H/15 * * * * ----this build happened every 5 minutes without commits ,if changes are commit or not but every 5 mints build happened in Jenkins
Description
Git url::
Build the branch
every 5 mints build will trigger
Build Periodically::: H/15 * * * * ----this build happened every 5 minutes without commits ,if changes are commit or not but every 5 mints build happened in Jenkins
click save
1.Setting up Jenkins Email Notifications allows you to alert your team when a build passes, fails, or encounters issues. Here's a step-by-step guide to configure it
- give continues Feedback to the Dev team via Email when a build passes, fails
Steps::
Go to mail
Click manage your google account
Click Security
Click protect your account
Click Add phone number
Click add phone
Make sure your account is protected
Make sure 2-steps Verification is ON
Credentials:
In search box App Password
Zvqxxvplduhrlffv --we should provide this password in Jenkins Email configuration level
Go to Jenkins ---> Manage Jenkins
System configurations
Go to Extended E-mail Notification
SMTP server :: smtp.gmail.com
SMTP Port:: 465
Credentials:: Username:: Your Email Password::Zvqxxvplduhrlffv
Select Use SSL
Default content type HTML
Default Triggers
E-mail Notification
Use SMTP Authentication? –should selected
Use SSL select
Port 465
Test configuration by sending test e-mail
Connection success
Post build action
Post build Action i want to published artifacts & test results
I'm going to created one free style job and configured Post-build Actions
In post build Action select the option Archive the artifacts
target/.war OR target/.jar OR target/.zip OR target/.ear
In post build Action select the option Publish JUnit test result report for to published the test results
target/surefire-reports/*.xml
ls target
Post build action stage
Select archive the artifact --target/*.jar
Junit test results:: --target/surefire-reports/*.xml
3.For every company will do sequence build on one project this is recommended approach
General ---just descriptin
SCM
where is your project--github, bitbucket
Triggere
whenever code changes i want build the project given time
Environmant
--all about workspaces folders
Build Steps
dev team will tell which tool we are using in current project
Post Build
devops engineer is aim is given continue feedback to dev team via email notification
Parameterized Jenkins Jobs ::
Run the same job with different inputs without modifying the configuration manually
Go To New Item
Enter Job Name, Free style project and click ok
Enter the description
Select the option This project is parameterised
Click Add Parameter
Select optiions String parameter or choise parameter or boolean parameter you can select the ny options based on your requirement
select string parameter
Select Choise Parameter
choise parameter
Click Save
You Can observed this project is parameterized
Click Build with parameter
select deployment environment
select which versioj you want to deployment like tis you can configured real time parameterized project in jenkins
Click Build
I want a build 3 projects ,one project build is success then it will start 2nd project & once 2nd project build is success then it will start 3rd Project, without manually interventions we need setup these 3 projects configurations.
I want a build 3 projects ,one project build is success then it will start 2nd project & once 2nd project build is success then it will start 3rd Project, without manually interventions we need setup these 3 projects configurations.
Project-A, Projec -B, Projec - C
Once Project-A build is done, then it will start Project-B build and once Project-B build SUccess then it will start Project-C build ---for this we need to select Add post-build action and select "Build other projects" in drop down and provide Project-B details.
Projec A is (Downstream project is ---Projec B)
Projec B is (UP Stream project is ----Projec A)
Projec C is (downstream project of --Projec B)
i created 3 free style project in jenkins
Github URL::: https://github.com/parasa7358/spring-petclinic.git
Post Build Action , select the option Build Other Project Project-B
Github URL:::https://github.com/parasa7358/onlinebookstore.git
Post Build Action , select the option Build Other Project Project-C
Github URL:::https://github.com/srinfotechbatch2/devOpsWeb.git
Pipelines Introduction:::
A Jenkins pipeline is a series of automated steps or stages that define the process of continuous integration/continuous delivery (CI/CD) for your code. Jenkins, being a popular open-source automation server, uses pipelines to automate tasks like building, testing, and deploying code.
There are two types of Jenkins pipelines:
-
Declarative Pipeline
-
Scripted Pipeline
-
Declarative Pipeline:: The declarative pipeline syntax is simpler and more structured. It's the recommended style for most users because it's easy to read and maintain
Steps
Click +New Item
Enter the Project Name And Click OK
At General Section Provide the Description
At Definition, We need to select the Pipeline Script
Here's an example of a simple declarative pipeline: Syntax
pipeline{
agent any
stages{
Stage ('Clone'){
steps{
// write code } }
Stage ('Build'){ steps{
// write code } // write code
}
Stage ('Test'){
steps{
// write code } // write code
} Stage ('Execute test casea and get the results'){
steps{
// write code } // write code
}
Stage ('Generated Artifact'){
steps{
// write code } // write code
}
Stage ('Deploy'){
steps{
// write code } // write code
}
// write code
}
}
Please try to create one pipeline job in jenkinsfile and execute the below Declarative pipeline example:;
pipeline {
agent any
stages {
stage('Clone') {
steps {
git branch: 'main', url: 'https://github.com/srinfotech7358/spring-petclinic.git'
}
}
stage('Build') {
steps {
bat 'mvn clean install'
}
}
stage('Test') {
steps {
bat 'mvn test'
}
}
}
}
Plugins in Jenkins are essential components that extend its core functionality, allowing you to customize Jenkins to meet specific CI/CD needs. Jenkins has a vast plugin ecosystem that supports building, deploying, and automating software projects across various platforms and tools
Step-by-Step: Log in to Jenkins as an administrator.
Navigate to Manage Jenkins (usually on the left sidebar).
Click on Manage Plugins.
(Image reference from Jenkins documentation)
Go to the Available tab.
Use the search box to find the plugin you want.
Check the box next to the plugin name.
Click:
Pipeline: Stage View Plugin in Jenkins The Pipeline: Stage View plugin is a visualization tool in Jenkins that allows users to see a graphical view of each stage in a pipeline. It provides a real-time and historical overview of pipeline execution per stage, making it easier to debug, monitor, and analyze performance.
Click the Build Now and we can triggered the pipeline
Success all the stages & Steps
pipeline: This is the top-level structure.
agent: Specifies where the pipeline will run, such as on any available agent, a specific node, or a Docker container.
stages: Defines the different steps or stages in the pipeline (e.g., Build, Test, Deploy).
steps: Commands to be executed in each stage.
Please try to create one pipeline job in jenkinsfile and execute the below Declarative pipeline example:;
pipeline {
agent any
stages { stage('Clone') { steps { git branch: 'main', url: 'https://github.com/srinfotech7358/spring-petclinic.git' } }
stage('Build') {
steps {
bat 'mvn clean install'
}
}
stage('Test') {
steps {
bat 'mvn test'
}
}
stage('Generate Junit Test Results') {
steps {
junit 'target/surefire-reports/*.xml'
}
}
stage('Generate Artifacts') {
steps {
archiveArtifacts artifacts: 'target/*.war', followSymlinks: false
}
}
} }
archive the artifact :: target/*.jar
Junit test results:: target/surefire-reports/*.xml
Both declarative and scripted pipelines are stored as Jenkinsfiles, which you place in your source code repository. This allows you to version control your pipeline and keep it aligned with your application code.
Both declarative and scripted pipelines are stored as Jenkinsfiles, which you place in your source code repository. This allows you to version control your pipeline and keep it aligned with your application code.
pipeline { agent any
stages {
stage('Clone') {
steps {
git branch: 'main', url: 'git@github.com:parasa7358/spring-petclinic.git'
}
}
stage('Build') {
steps {
sh 'mvn package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('Test Results Reports') {
steps {
junit 'target/surefire-reports/*.xml'
}
}
stage('Artifacts') {
steps {
archiveArtifacts artifacts: 'target/*.war', followSymlinks: false
}
}
stage('Deploy') {
steps {
echo 'Hello World'
}
}
}
}
This pipeline:::
1 Checks out the source code from your Git repository.
- Builds the project using Maven.
3.Runs unit tests.
4.Deploys the application using a custom script.
JOb creation::
Branches to build
Script Path::: This path is Jenkinsfiles where we maintained in github source code level
node{
stage('clone'){
git branch: 'main', url: 'https://github.com/srinfotechbatch2/spring-petclinic.git'
}
stage('build'){
bat 'mvn clean install'
}
stage('Test'){
bat 'mvn test'
}
stage('Artifacts'){
archiveArtifacts artifacts: 'target/*.jar', followSymlinks: false
}
stage('generated test reports'){
junit 'target/surefire-reports/*.xml'
}
}
github sourcecode jenkinsfile
Apache Tomcat is an open-source web server and servlet container developed by the Apache Software Foundation. It is primarily used to serve Java applications and is one of the most popular servlet containers in the world.
Tomcat is an essential tool for anyone working with Java web applications. It provides a simple, reliable platform for deploying and managing Java Servlets and JSPs and is widely used in both development and production environments. Its ease of use, combined with powerful features and flexibility, makes it an ideal choice for many developers working on Java-based web applications.
Apache Tomcat is an open-source web server and servlet container that is primarily used to serve Java-based web applications. It implements several Java EE (Enterprise Edition) specifications, such as Java Servlet, JavaServer Pages (JSP), and WebSocket, among others. Tomcat is often used to run Java applications on the web because it's lightweight, easy to configure, and widely supported.
Here are some key points about Tomcat:
-
Servlet Container: Tomcat is a servlet container, meaning it manages the lifecycle of Java Servlets, which are small Java programs that run on a web server.
-
JSP Support: Tomcat also supports JavaServer Pages (JSP), a technology that allows for embedding Java code within HTML pages.
-
Configuration: It’s highly configurable through XML files, like
server.xmlfor server settings,web.xmlfor application settings, and others. -
Lightweight: Unlike full-fledged application servers like WildFly (formerly JBoss) or GlassFish, Tomcat is primarily a servlet and JSP container, which makes it lighter and easier to deploy for simpler Java web applications.
-
Performance: It’s known for good performance in handling static content, making it a popular choice for Java web developers.
https://tomcat.apache.org/download-90.cgi
64-bit Windows zip
Integrating Tomcat with Jenkins is a common use case for automating the deployment of Java-based web applications. Jenkins can be set up to deploy a web application to a Tomcat server whenever a new build is triggered.
Prerequisites:
Apache Tomcat should be installed and running on your server. Jenkins should be installed and running.
Steps to integrate Jenkins with Tomcat:
- Install the "Deploy to Container" Plugin in Jenkins: The easiest way to deploy to Tomcat from Jenkins is by using the Deploy to Container plugin. This plugin allows Jenkins to deploy WAR files to a Tomcat server.
Go to your Jenkins dashboard. Click on Manage Jenkins > Manage Plugins. In the Available tab, search for Deploy to Container Plugin and install it. Once installed, restart Jenkins to apply the plugin.
- Configure Tomcat Server in Jenkins: Now you need to tell Jenkins where your Tomcat server is running.
In Jenkins, go to Manage Jenkins > Configure System. Scroll down to the Deploy to container section. Click Add Tomcat Server.
Provide the necessary information: Name: Give the Tomcat server a name (Tomcat9). URL: The URL of your Tomcat server (e.g., http://localhost:8080). Username: The username for Tomcat's manager app (usually admin). Password: The password for that username (set in Tomcat's tomcat-users.xml). Save the configuration.
- Configure Tomcat’s tomcat-users.xml: Make sure Tomcat is set up to allow Jenkins to deploy the application by editing the tomcat-users.xml file.
Restart Tomcat to apply the changes.
- Create a Jenkins Job to Build and Deploy the Application: Next, you need to create a Jenkins job that will build your web application (e.g., a WAR file) and deploy it to Tomcat.
From the Jenkins dashboard, click New Item.
Select Freestyle Project, give it a name, and click OK.
In the job configuration, go to the Build section and configure your build step, such as building a Maven project For Maven, you can use:
mvn clean install
In the Post-build Actions section, add Deploy war/ear to a container.
In the WAR/EAR files field, provide the path to your WAR file (e.g., target/my-app.war). In the Container field, choose the Tomcat server you configured earlier. Set the Context Path (e.g., IfocusAWSDevOpsTraining), which is the URL path where the application will be accessible on Tomcat. If you want Jenkins to deploy automatically after every successful build, check the option Deploy after every successful build. Save the job.
- Trigger the Build and Deployment: Go to the Jenkins job you just created and click Build Now to trigger a build. After the build completes, Jenkins should deploy the WAR file to your Tomcat server.
You can access your application by going to http://<tomcat_host>:<tomcat_port>/<context_path>
example:: http://localhost:8080/IfocusApplication/
POLL SCM:: * * * * * (every minute automatic build & deployment happend when new commits happend in github) This setup will allow Jenkins to automatically build and deploy your Java web application to Tomcat with each new build
Polling SCM (Source Code Management) and webhooks are two common methods used for integrating continuous integration (CI) systems or automating tasks based on changes in repositories.
- Polling SCM Polling SCM is a method where a system (like Jenkins, GitLab CI, etc.) periodically checks the source code repository for changes. If it detects changes, it triggers the build process or some other automated task.
How it works:
A job is set up to check the SCM (like GitHub, GitLab, Bitbucket, etc.) at regular intervals (e.g., every minute or hour).
The CI server pulls the repository to see if there are any new commits since the last poll.
If changes are detected, it triggers the CI/CD pipeline to build, test, or deploy the application.
- Webhooks Webhooks provide a more efficient method for triggering actions based on changes in the repository. Rather than the CI system polling for changes, the source control platform sends an HTTP POST request (webhook) to the CI system when an event (like a commit or pull request) occurs.
Github Project URL:::
https://github.com/srinfotech7358/onlinebookstore.git
TomcatIntegarteWithJenkins::
POLL SCM
Build Steps
Post-build Actions
Deploy war/ear to a container
WAR/EAR files ----> target/*.war
Context path ---> SRinfotechAWSTraing
Tomcat 9.x Remote
Tomcat URL:: http://localhost:8080
Continuous Integration(CI)::the practice of automating the integration of code changes from multiple Developers into a single software project. It's a primary DevOps best practice, allowing developers to frequently merge code changes into a central repository,after which automated builds and tests are run automatically.
developers frequently commit to a shared repository using a version control system such as Git,A continuous integration automatically builds and runs unit tests on the new code changes to immediately using jenkins Orchestration.
Continuous Deployment(CD) :: Continuous Deployment is an extension of continuous delivery. With continuous deployment, every change that passes through the automated tests and builds is automatically deployed to production without any human intervention. The deployment process is fully automated.
Continuous Delivery (CD)::Continuous Delivery is a software development practice in which code changes are automatically built, tested, and prepared for release to production in a consistent and reliable manner. The key distinction of continuous delivery is that the process of deploying the code to production is done manually by a human decision-maker.
please create one new pipeline job
Provide the Description
Enabled POLL SCM
In Pipeline Section write groovy script using Declarative style
pipeline { agent any
tools{
maven 'maven'
}
stages{ stage('Git checkout'){
steps{
git branch: 'main' url: 'https://github.com/parasa7358/Petclinic.git'
}
}
stage('clean and install'){
steps{
sh 'mvn clean install'
}
}
stage('Package'){
steps{
sh 'mvn package'
}
}
stage('Archive the Artifacts'){
steps{
sh 'mvn clean install'
}
post{
success{
archiveArtifacts artifacts: '**target/*.war'
}
}
}
stage('Test Cases'){
steps{
sh 'mvn test'
}
}
stage('Deploy to tomcat server'){
steps{
deploy adapters: [tomcat9(credentialsId: 'tomcat9credentials', path: '', url: 'http://localhost:8080/')], contextPath: 'SRINFOTECH', war: '**/*.war'
}
}
} }
Run the job
To integrate Jenkins with Tomcat using the Declarative Pipeline approach, you'll be using Jenkins Pipeline syntax to automate the deployment process to a Tomcat server. This process typically involves building the application, packaging it, and then deploying it to Tomcat.
- Jenkinsfile Configuration (Declarative Pipeline)
In your Jenkins project, you'll create a Jenkinsfile, which contains the Declarative Pipeline syntax. This file defines the steps involved in the CI/CD pipeline.
Please execute below script in jenkins pipeline job using Declarative style
pipeline { agent any
tools{
maven 'maven'
}
stages{ stage('Git checkout'){
steps{
git branch: 'main', url: 'https://github.com/srinfotechbatch2/Petclinic.git'
}
}
stage('clean and install'){
steps{
bat 'mvn clean install'
}
}
stage('Package'){
steps{
bat 'mvn package'
}
}
stage('Archive the Artifacts'){
steps{
bat 'mvn clean install'
}
post{
success{
archiveArtifacts artifacts: '**target/*.war'
}
}
}
stage('Test Cases'){
steps{
bat 'mvn test'
}
}
stage('Deploy to tomcat server'){
steps{
deploy adapters: [tomcat9(credentialsId: 'tomcat9credentials', path: '', url: 'http://localhost:8080/')], contextPath: 'SRINFOTECH', war: '**/*.war'
}
}
} }
pipeline { agent any
stages {
stage('Clone') {
steps {
git branch: 'master', url: 'https://github.com/srinfotech7358/onlinebookstore.git'
}
}
stage('Build') {
steps {
bat 'mvn clean install'
}
}
stage('Generate Artifacts') {
steps {
archiveArtifacts artifacts: 'target/*.war', followSymlinks: false
}
}
stage('Deploy to Tomcat Server') {
steps {
deploy adapters: [tomcat9(alternativeDeploymentContext: '', credentialsId: 'Tomcat', path: '', url: 'http://localhost:8080')], contextPath: 'SR INFOTECH SOLUTIONS PVT LIMITED', war: 'target/*.war'
}
}
}
}
SonarQube is an open-source platform developed by SonarSource that is used for continuous inspection of code quality. It helps developers and development teams identify bugs, code smells, vulnerabilities, and duplication in their codebases across multiple programming languages.
Key Features of SonarQube Static Code Analysis SonarQube analyzes source code without executing it, detecting issues like:
Bugs
Vulnerabilities
Code smells (bad design or coding practices)
Duplications
Technical debt
Sonarqube installed link::
https://gist.github.com/dmancloud/0abf6ad0cb16e1bce2e907f457c8fce9
default U/P ---admin/admin
default port number:: 9000
Server URL: URL to your SonarQube instance (e.g., http://localhost:9000). and default port is 9000
To integrate SonarQube with Jenkins, you need to ensure that Jenkins can communicate with your SonarQube server to perform static code analysis during your CI/CD pipeline. This will allow you to analyze your code quality and get reports from SonarQube as part of your build process.
Here's how you can integrate SonarQube with Jenkins:please follow below steps
- Install the SonarQube Plugin in Jenkins Before you start, ensure that you have the SonarQube Scanner Plugin installed in Jenkins:
Go to Jenkins Dashboard. Click on Manage Jenkins → Plugins. Go to the Available tab, and search for SonarQube Scanner. Install it and restart Jenkins.
- Configure SonarQube in Jenkins Next, you need to configure SonarQube on Jenkins so it can communicate with your SonarQube server.
Go to Jenkins Dashboard. Click on Manage Jenkins → Configure System. Scroll down to the SonarQube servers section and click Add SonarQube.
Name::: Give your SonarQube instance a name (SonarQubeServer). Server URL: URL to your SonarQube instance (e.g., http://localhost:9000). and default port is 9000 Server Authentication Token: You can generate a token in SonarQube by navigating to My Account → Security → Generate Tokens. Paste this token into Jenkins. Click Save.
- Configure the SonarQube Scanner in JenkinsSteps: =============================================== In the Configure System page, scroll to the SonarQube Scanner section. Click Add SonarQube Scanner and select SonarQube Scanner for Jenkins.
If you want to use a custom installation, specify the path to the SonarQube Scanner binary. Click Save.
Go to your SonarQube server (e.g., http://localhost:9000). Create a project or use an existing one. Obtain the Project Key from the SonarQube project and update the pipeline script as shown in the sonar.projectKey parameter.
Go to Projects and click Local project
Click Next
Selected Use the global setting
Click Create Project
Now Spring-petclinic Project created in Sonarqube
Click Locally
Click Generate for Token
Analyze "spring-petclinic12": sqp_0eb364758c5186bea4077eff841ddb99ba89a3ab
Click Continue
Selected Maven and copy below script from sonarqube and it will help to integrate Sonarqube with jenkins pipeline
mvn clean verify sonar:sonar
-Dsonar.projectKey=spring-petclinic12
-Dsonar.projectName='spring-petclinic12'
-Dsonar.host.url=http://localhost:9000
-Dsonar.token=sqp_0eb364758c5186bea4077eff841ddb99ba89a3ab
Go To jenkins and create new job IntegrateSonarqubeWithJenkins
Please use below script to run the pipeline job
pipeline { agent any
tools{
maven 'maven'
}
stages{ stage('Git checkout'){
steps{
git branch: 'main', url: 'https://github.com/parasa7358/Petclinic.git'
}
}
stage('clean and install'){
steps{
bat 'mvn clean install'
}
}
stage('Package'){
steps{
bat 'mvn package'
}
}
stage('Archive the Artifacts'){
steps{
bat 'mvn clean install'
}
post{
success{
archiveArtifacts artifacts: '**target/*.war'
}
}
}
stage('Test Cases'){
steps{
bat 'mvn test'
}
}
stage('Sonarqube Analysis'){
steps{
bat 'mvn clean package'
bat '''mvn sonar:sonar \
-Dsonar.projectKey=spring-petclinic
-Dsonar.projectName='spring-petclinic'
-Dsonar.host.url=http://localhost:9000
-Dsonar.token=sqp_8d74d659dbf3d3bf2924a0d24104f5ddba914fac'''
}
}
stage('Deploy to tomcat server'){
steps{
deploy adapters: [tomcat9(credentialsId: 'tomcat9credentials', path: '', url: 'http://localhost:8080/')], contextPath: 'Ifocus Solutions Pvt Ltd', war: '**/*.war'
}
}
} }
- please start Jenkins on your machine & make sure Jenkins server is UP & Running state
- please start Tomcat on your machine & make sure Tomcat server is UP & Running state
- please start Sonarqube on your machine & make sure Sonarqube server is UP & Running state
once above steps done then we can execute below script
pipeline{
tools{
maven 'Maven'
}
agent any
stages{
stage('Clone'){
steps{
git branch: 'main', url: 'https://github.com/srinfotech7358/Petclinic.git'
}
}
stage('Build') {
steps {
bat 'mvn clean install'
}
}
stage('Test Cases') {
steps {
bat 'mvn test'
}
}
stage('Archive the Artifacts') {
steps {
archiveArtifacts artifacts: 'target/*.war', followSymlinks: false
}
}
stage('Sonarqube Analysis') { steps {
bat 'mvn package'
bat '''mvn sonar:sonar \
-Dsonar.projectKey=spring-petclinic \
-Dsonar.projectName='spring-petclinic' \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.token=sqp_96cf5222ab632b69c14baa5590210a7125185d5a'''
}
}
stage('Deploy Application into Tomcat Server') { steps { deploy adapters: [tomcat9(alternativeDeploymentContext: '', credentialsId: 'NewTomcat', path: '', url: 'http://localhost:8080/')], contextPath: 'Test', war: 'target/*.war' } }
}
}
Once sonarqube scanner done, please verify the sonarqube dashboard for reports & results
Go to Administration
Click Projects & Select Background Tasks
You can able to see all scanned projects status
Click on any Project, see the PASSED the quality gates
Click on Overall Code option
see the results
here Code coverage is
Coverage 82.7%
NOTE:: Coverage is greater than or equal to 80.0%, this should be maintained minimum % every project
NOTE:::Duplicated Lines (%) is less than or equal to 3.0%
Go to Dashboard click on Quality Gates
at left side we can see create & just click on it
Provide the Name & Click Create
Your own quality gates are created
this is your own quality gates
nditions on New Code Metric Operator Value Issues is greater than 0 Security Hotspots Reviewed is less than 100% Coverage is less than 80.0%
Duplicated Lines (%) is greater than
select your project
apply the Grant permissions to a user or a group
Apply all the permissions & click Add
go to Quality Profiles
select Language
total java Rules 527
at right saide top click create
provide the Language & Name and click Create
your own profile
click Active More rules
Bulk Change
Activate In Spring-pipeline project
Sure Apply
Succcessfully Applied my own quality profile rules
Activate In Quality Profile (683 rules)
Now we are successfully onboarded spring-petclininc project to Sonarqube server
Running the Pipeline Once the pipeline is configured, Jenkins will execute the SonarQube analysis during the build process. After the build completes, you can view the analysis results in your SonarQube dashboard.
Code coverage Code smells Bugs Vulnerabilities Duplications These reports will be available in the SonarQube dashboard for your project.
JFrog Artifactory is a universal artifact repository manager that serves as a central hub for storing, managing, and distributing software artifacts, binaries, packages, and other assets throughout the software development lifecycle, improving automation, and ensuring release integrity.
Artifact Repository Management:
Allows for storing binaries and artifacts (e.g., libraries, packages, Docker images) in a centralized location. Supports all major package types (e.g., Maven, Gradle, npm, NuGet, RubyGems, etc.). Version Control:
Helps in managing versions of your artifacts and ensures the correct version is used during builds and deployments. Integration with CI/CD:
Integrates seamlessly with CI/CD tools like Jenkins, Bamboo, GitLab CI, and others. Enables automated publishing of artifacts as part of your continuous integration pipeline. Access Control & Security:
Provides fine-grained access control and permissions for users and groups. Supports user authentication, security, and audit trails to ensure compliance and secure artifact management. Replication:
Allows you to replicate artifacts across multiple Artifactory instances, ensuring high availability and disaster recovery capabilities. Remote Repositories:
Artifactory can proxy remote repositories, allowing you to cache and fetch external dependencies without re-downloading them each time. Promotion & Release Management:
You can "promote" artifacts from one repository to another (e.g., from a development repository to a production repository), allowing for better control over releases. Multi-Platform Support:
Artifactory supports multiple programming languages and platforms, making it a universal solution for managing software dependencies and releases.
Please go throw the recorded video session and follow the steps to create the free tier AWS account.Let me know if anyone facing any issues.
Amazon Web Services (AWS) is a comprehensive and widely adopted cloud platform offered by Amazon. It provides a broad set of services to help organizations and individuals build and scale applications, manage data, and process workloads in the cloud. AWS is designed to provide flexible, scalable, and cost-effective solutions for computing, storage, networking, machine learning, and much more.
First Step:: https://jfrog.com/download-jfrog-platform/ ---download url
previous versions link
https://jfrog.com/download-legacy/?product=artifactory&version=7.104.12
All zip version and search 6.12.1 OSS version
https://releases.jfrog.io/artifactory/bintray-artifactory/
JDK 12.1.0
https://www.oracle.com/in/java/technologies/javase/jdk12-archive-downloads.html
artifactory-oss-6.12.1
All zip version and search 6.12.1 OSS version
https://releases.jfrog.io/artifactory/bintray-artifactory/
stage ('Artifactory Server'){ steps { rtServer ( id: "Artifactory", url: 'http://localhost:8081/artifactory', username: 'admin', password: 'password', bypassProxy: true, timeout: 300 ) } } stage('Upload'){ steps{ rtUpload ( serverId:"Artifactory" , spec: '''{ "files": [ { "pattern": "*.war", "target": "ifocus-solutions-pvt-ltd" } ] }''', ) } } stage ('Publish build info') { steps { rtPublishBuildInfo ( serverId: "Artifactory" ) } }
After installed Artifactory plugin
Go to Manage Jenkins--> System configuration find JFROG
Click JFrog Platform Instances
For user name and password
Default Jfrog U/P----admin/password
I need to setup target in Jfrog
srinfotech-batch2
click Local repository
Select maven
Repository key :::: srinfotech-batch2
Click save and finish
Go to artifacts and check repository is created with name -srinfotech-batch2
pipeline{ agent any
tools{
maven 'Maven'
}
stages{ stage('Clone The Project'){ steps{ git branch: 'main', url: 'https://github.com/srinfotechbatch2/Petclinic.git' } } stage('Build'){ steps{ bat 'mvn clean install' } } stage('Test'){ steps{ bat 'mvn test' } } stage('Generated the test reports'){ steps{ junit 'target/surefire-reports/.xml' } } stage('published the Artifacts'){ steps{ archiveArtifacts artifacts: 'target/.war', followSymlinks: false } }
stage('SonarQube Analysis'){
steps{
bat 'mvn package'
bat '''mvn sonar:sonar \
-Dsonar.projectKey=spring-petclinic
-Dsonar.projectName='spring-petclinic'
-Dsonar.host.url=http://localhost:9000
-Dsonar.token=sqp_b4f05b06814df65b8d3f1a467f3ed604e2dadb03'''
}
}
stage ('Artifactory Server'){
steps {
rtServer (
id: "Artifactory",
url: 'http://localhost:8081/artifactory',
username: 'admin',
password: 'password',
bypassProxy: true,
timeout: 300
)
}
}
stage('Upload'){
steps{
rtUpload (
serverId:"Artifactory" ,
spec: '''{
"files": [
{
"pattern": "*.war",
"target": "srinfotech-batch2"
}
]
}''',
)
}
}
stage ('Publish build info') {
steps {
rtPublishBuildInfo (
serverId: "Artifactory"
)
}
}
stage('Deploy to Tomcat Server'){
steps{
deploy adapters: [tomcat9(alternativeDeploymentContext: '', credentialsId: 'tomcatcredential', path: '', url: 'http://localhost:8080')], contextPath: 'SRInfotechSpringpetclinicJfrog', war: 'target/*.war'
}
}
}
}
Amazon Web Services (AWS) is a comprehensive and widely adopted cloud platform offered by Amazon. It provides a broad set of services to help organizations and individuals build and scale applications, manage data, and process workloads in the cloud. AWS is designed to provide flexible, scalable, and cost-effective solutions for computing, storage, networking, machine learning, and much more.
AWS ---Amazon web services
compute services:: Amazon EC2 (Elastic Compute Cloud): Provides scalable virtual servers to run applications. AWS Lambda: Lets you run code without provisioning or managing servers. It automatically scales based on usage.
Storage services:: Amazon S3 (Simple Storage Service): Object storage for storing and retrieving large amounts of data. Amazon EBS (Elastic Block Store): Persistent block-level storage for EC2 instances.
Database:: Amazon RDS (Relational Database Service): Managed relational database service supporting multiple database engines (e.g., MySQL, PostgreSQL, MariaDB, etc.). Amazon DynamoDB: A managed NoSQL database service. Amazon Aurora: A high-performance relational database engine compatible with MySQL and PostgreSQL.
Network services:: Amazon VPC (Virtual Private Cloud): Lets you create isolated networks within AWS for secure connections.
Security ::
AWS IAM (Identity and Access Management): Controls user access and permissions for AWS resources. AWS KMS (Key Management Service): Managed service for creating and controlling encryption keys. Security groups ---inbound, outbould roles
Containers & kuberneties:: ECS ---elastic containers servcies EKS ----estastic kuberneties services AKS ---Azure kuberneties services
Cloud watch --Metrics Monitoring
CloudWatch Metrics allows you to track the performance and utilization of AWS resources such as EC2 instances, RDS databases, Lambda functions, S3 buckets, and much more. These metrics include CPU utilization, disk activity, network traffic, and others. You can create custom metrics for your applications or services as well.
cloud trail ---Security Monitoring:
Use CloudTrail logs to detect unauthorized access or activity in your AWS environment. You can track changes in security settings, unauthorized API calls, or unexpected configuration changes.
Developer Tools:: AWS CodeCommit: Source control service for managing your code repositories. AWS CodeDeploy: Automates code deployments to EC2 instances and Lambda. AWS CodePipeline: Continuous integration and continuous delivery (CI/CD) service for automating the release pipeline.
Amazon Elastic Compute Cloud (Amazon EC2) is one of the core services provided by Amazon Web Services (AWS)
Wide Variety of Instance Types:
EC2 instances are grouped into families based on the type of workload they are optimized for. Some common instance families include: General Purpose: e.g., t3, m5 instances (balanced CPU, memory, and networking). Compute Optimized: e.g., c5 instances (great for high-performance computing tasks). Memory Optimized: e.g., r5, x1e instances (designed for high-memory workloads like databases).
Go to AWS ans Search EC2
Click EC2
Go to instances at left side bar
Click Launch Instances, EC2 ---> Instances -----> Launch an instance
Select Ubuntu
Select Amazon Machine Image (AMI)
select Instance type,t2 medium
Create Create new key pair and provide key pair name
click create pair
click launch instance
instance will be created
i have to create 2 EC2 ubuntu machines in AWS
- Jenkinsmaster
- Node
we have already .pem file dowloaded in you local machin
right click from .pem and click Open git bash here option Now Go to AWS Ubuntu machine which is already created in AWS insatnces and select master machine
Click Connect
Click SSH Client
Copy URL
ssh -i "Newkeysmasternode.pem" ubuntu@ec2-18-237-178-192.us-west-2.compute.amazonaws.com
Now past that url in Gitbash
switch to root user below command run
Sudo -i
update the all packages ,please run below command
sudo apt-get update
JDK link
https://bluevps.com/blog/how-to-install-java-on-ubuntu
MAven link
https://phoenixnap.com/kb/install-maven-on-ubuntu
sudo apt-get install maven java -version mvn -v
Set java home environment
sudo vi /etc/environment JAVA_HOME=”/usr/lib/jvm/java-8-openjdk-amd64/jre” MAVEN_HOME=”/usr/share/maven”
Reload your system environment
source /etc/environment
Veriy the variables was set correctly
echo $JAVA_HOME echo $MAVEN_HOME
https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-22-04
https://phoenixnap.com/kb/install-jenkins-ubuntu
AWS any machines default password authentication is disabled , we need to enabled in any linux machines
sudo vi /etc/ssh/sshd_config sudo service sshd restart In EC2 – by default password based authentication is disabled so we need to enabled
sudo vi /etc/ssh/sshd_config passwordauthentication :yes
In ubuntu machine default user is not sudo user,
visudo Jenkins ALL=(ALL:ALL) NOPASSWD:ALL su Jenkins Switching to new user
Once installed Jenkins successfully
we need to enabled the Inbounds and outbounds rules in AWS security groups
Inbounds rules
Copy public IP address and go to browser Access Jenkins using Public IP address http://35.86.160.156:8080/
bydefault Jenkins runs on port 8080 Jenkins home path/var/lib/Jenkins How to change the port number in Jenkins:: https://stackoverflow.com/questions/28340877/how-to-change-port-number-for-jenkins-installation-in-ubuntu-12-04
sudo nano /etc/default/jenkins
Please insatll JDK & Maven in node machine and setup environemnt varibles
sudo apt-get install maven
java -version
mvn -v
Set java home environment
sudo vi /etc/environment
JAVA_HOME=”/usr/lib/jvm/java-8-openjdk-amd64/jre”
MAVEN_HOME=”/usr/share/maven”
Reload your system environment
source /etc/environment
Veriy the variables was set correctly
echo $JAVA_HOME
echo $MAVEN_HOME
comminicate master & node via SSH keys
ssh-keygen
after generated copy the public & Private keys to node machine
option-1 to copy keys from master to node
ssh-copy-id user@ipaddressofnodemachine
ssh-copy-id node@172.31.44.169
2nd option --copy keys manually from master to node
3rd options --i have created authorized_keys file in node machine and copy public key from master to node
Master Node Configuration::
got to manage Jenkins
manage Nodes
click new node
Remote root directory
/home/node
Launch methods via ssh
Add credentials
option-1::
this time please use credentials option SSH key with private key from node machine
sudo -i sudo apt update java --version mvn -v
environment setup::
Maven home: /usr/share/maven
sudo apt install maven
Java Home:: /usr/lib/jvm/java-17-openjdk-amd64
sudo apt install openjdk-17-jdk
sudo vi /etc/environment
1.press i from your keyboard 2.press the esc from your keyboard 3. shift+: 4. wq 5. press Enter
echo $JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64
echo $MAVEN_HOME /usr/share/maven
ssh-keygen -t ed25519
su su jenkins
visudo
jenkins ALL=(ALL:ALL) NOPASSWD:ALL
ctrl+X yes enter
in aws passwordauthenticatuion is disabled , you need to enabled the passwordauthentication
sudo vi /etc/ssh/sshd_config
PasswordAuthentication yes
NODE Machine::
1.sudo adduser node 2.user should provide the sudo permissions
visudo
node ALL=(ALL:ALL) NOPASSWD:ALL
3.passwordauthentication is enabled
sudo vi /etc/ssh/sshd_config cd ~
ssh node@172.31.37.219





























































































































































