0% found this document useful (0 votes)
19 views

Department of Computer Science and Engineering (AI & ML) : Sai Spurthi Institute of Technology

Uploaded by

dhanushalladi51
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Department of Computer Science and Engineering (AI & ML) : Sai Spurthi Institute of Technology

Uploaded by

dhanushalladi51
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 89

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

(AI & ML)

DEVOPS LAB
MANUAL

SAI SPURTHI INSTITUTE OF TECHNOLOGY


B. Ganagaram, Sathupally, Khammam – 507303 (T.S)
CERTIFICATE

This is certify that it is a bonafide record of practical Work of Mr. /


Miss……………………………RollNo……………..…….…of……………… B.Tech....…….
……………sem. In the Department of
…………………………………………………………..Engineering[AI&ML],
In……………………………………….Laboratory during the Academic
year……………………….

No. of Experiments Conducted………………. No. of Experiments


Attended…………….

Signature of the Staff Member Signature of Head of the


Department

Signature of the External Examiner


S.NO Date Name of the experiment Page no Remarks

1. Write code for a simple user registration form for an


event.

2. Explore Git and GitHub commands Aim: Explore Git and


GitHub commands

3. Practice Source code management on GitHub.

4. Jenkins installation and setup, explore the environment.

5. Demonstrate continuous integration and development


using jenkins

6. Explore Docker commands for content management

7. Develop a simple containerized application using Docker.

8. Integrate Kubernetes and Docker

9. Program for x-path

10. Install and Explore Selenium for automated testing.

11. write a simple program in javascript and perform testing


using selenium.

12. Develop the test cases for the above containerized


application using selenium.

13 Sonarqube integration with jenkins


1.Write code for a simple user registration form
for an event
Program:-
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<link type="stylesheet" href="styles.css">
<style>
body{
background-color:red;
}
.bg{
background-color: green;
</style>
</head>
<body>
<center class="bg">
<h1>Registration Page</hi>
<form action = "registration" method="GET">
<label>First Name </Label>
<input type="text" name="name" placeholder= "Enter Your name"><br>
<label> Date Of Birth</label>
<input type="date" name="dob"><br>
<label>Email</label>
<input type="email" name="email" placeholder="enter email"><br>
<label> Gender</label>
<input type = "radio" name="Gender"> Male </input>
<input type="radio" name = "Gender"> female</input>
<br>
<label> Phone No</label>
<input type="number" name: "Phno"></input>
<br>
<label>Address</label>
<input type="rextasen" rows=5 cols=5 name="adde"></input>
<br>
<input type="checkbox"> Accept terms and conditions
<br>
<label>Branch</label>
<select name="Ops">
<option value=05>CSE </option>
<option value=66 >csm</option>
<option value=027> EEE </option>
<option value=04> 042 ECE </option>
</select>
<br>
<button type="submit">Submit </button>
<button type="reset"> Reset</button>
</form>
</center>
</body>
</html>

Output:

2.Explore Git and GitHub commands Aim: Explore Git and GitHub
commands
EXPERIMENT NO:2. Explore Git and GitHub commands.
Aim: Explore Git and GitHub commands
DESCRIPTION: Git and GitHub are two of the most popular tools used for version control and
collaboration in software development.
mkdir :- It is used to create new directory(or multiple folders)in the file system.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
$ mkdir demo1
cd :- The cd command, also known as chdir (change directory), is a line shell
command used to change the current working directory.
hp@DESKTOP V04ALOG MINGW64/c/Devops/projects/demo1/demo1
$ cd demo1
git init:- Create empty Git repo in specified directory. Run with no arguments
to initialize the current directory as a git repository
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
$ git init
Initialized empty Git repository in C:/DevopsLab/projects/demo1/.git/
ls -a :- This command is used for listing the contents that match the
specified file pattern.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ ls -a
./ ../ .git/
git config user.name:-Define author name to be used for all commits in current repo.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master) $ git config user.name chdeepthi6612
git config user.email:-Define author email to be used for all commits in current repo
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git config user.email [email protected]
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
mkdir :- It is used to create new directory(or multiple folders)in the file System.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ mkdir src
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
src/

nothing added to commit but untracked files present (use "git add" to track)
git add:-Stage all changes in for the next commit. Replace with a to change a
specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git add index.html
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/
git rm –cached:-Removes the file only from the Git repository, but not from the filesystem.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git rm --cached index.html
rm 'index.html'
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git status
On branch master

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
src/

nothing added to commit but untracked files present (use "git add" to track)
git add:-Stage all changes in for the next commit. Replace with a to change a
specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git add index.html
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git commit -m "added index.html"
[master (root-commit) 7dd2dae] added index.html
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git add .
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/Main.py
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git commit -m "added Main.py file"
[master 840c954] added Main.py file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 src/Main.py
git branch:-List all of the branches in your repo. Add a argument to create a new branch with the name.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git branch
* master
Git remote:-The git remote command lets you create, view, and delete
connections to other repositories.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git remote
git remote add:-Create a new connection to a remote repo. After adding a remote, you can use as a shortcut for in other commands.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git remote add origin https://github.com/chdeepthi6612/gitcheatsheet.git
Git remote:-The git remote command lets you create, view, and delete
connections to other repositories.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git remote
origin
git push:- Push the branch to , along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git push -u origin master
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 492 bytes | 492.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/chdeepthi6612/gitcheatsheet.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean


vi:-It is an editor
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ vi index.html
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:


(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.html

no changes added to commit (use "git add" and/or "git commit -a")

git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git add index.html
warning: in the working copy of 'index.html', LF will be replaced by CRLF the next time Git touches it
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git add index.html
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git commit -m "updated index.html file"
[master eab7cde] updated index.html file
1 file changed, 1 insertion(+)
git push:- Push the branch to , along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 308 bytes | 308.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/chdeepthi6612/gitcheatsheet.git
840c954..eab7cde master -> master
vi:-It is an editor.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ vi index.html
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git add index.html
warning: in the working copy of 'index.html', LF will be replaced by CRLF the next time Git touches it
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git add index.html
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git commit -m "updated again index.html"
[master e1154b0] updated again index.html
1 file changed, 3 insertions(+), 1 deletion(-)
git push:- Push the branch to , along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git push
To https://github.com/chdeepthi6612/gitcheatsheet.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/chdeepthi6612/gitcheatsheet.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git pul:-fetch and merge any commits from the tracking remote branch
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master)
$ git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 950 bytes | 95.00 KiB/s, done.
From https://github.com/chdeepthi6612/gitcheatsheet
eab7cde..d1d593a master -> origin/master
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
vi:-It is an editor.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master|MERGING)
$ vi index.html
git add:-Stage all changes in for the next commit. Replace with a to change a
specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master|MERGING)
$ git add .
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master|MERGING)
$ git commit -m "merge conflicts resolved"
[master 4264bba] merge conflicts resolved
git push:- Push the branch to , along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/projects/demo1/demo1
(master|MERGING)
$ git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 12 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 659 bytes | 659.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/chdeepthi6612/gitcheatsheet.git
d1d593a..4264bba master -> master

ls:-The ls command lists the current directory contents and by default will not show hidden files.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git
$ ls
mkdir :- It is used to create new directory(or multiple folders)in the file System
hp@DESKTOP V04ALOG MINGW64/c/Devops/git
$ mkdir projects
cd :- The cd command, also known as chdir (change directory), is a line shell command used to change the current working directory.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git
$ cd projects
ls:-The ls command lists the current directory contents and by default will not show hidden files.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git
$ ls
git clone:-It retrieve an entire repository from a hosted location via URL.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git
/projects
$ git clone https://github.com/chdeepthi6612/simple-java-maven-app.git
Cloning into 'simple-java-maven-app'...
remote: Enumerating objects: 191, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 191 (delta 2), reused 8 (delta 2), pack-reused 182
Receiving objects: 100% (191/191), 40.25 KiB | 452.00 KiB/s, done.
Resolving deltas: 100% (58/58), done.
ls:-The ls command lists the current directory contents and by default will not show hidden files.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project
$ ls
simple-java-maven-app/
ls -a :- This command is used for listing the contents that match the specified file pattern.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project
$ ls -a
./ ../ simple-java-maven-app/
ls:-The ls command lists the current directory contents and by default will not show hidden files.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project
$ ls simple-java-maven-app/
README.md demo jenkins/ pom.xml src/

hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project


$ cd simple-java-maven-app/
ls:-The ls command lists the current directory contents and by default will not show hidden files.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ ls
README.md demo jenkins/ pom.xml src/
ls -a :- This command is used for listing the contents that match the specified file pattern.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ ls -a
./ ../ .git/ .gitattributes .github/ .gitignore README.md demo jenkins/ pom.xml src/
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
git status:- List which files are staged, unstaged, and untracked.
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:


(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: pom.xml

no changes added to commit (use "git add" and/or "git commit -a")
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:


(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: pom.xml

Untracked files:
(use "git add <file>..." to include in what will be committed)
documentation.txt

no changes added to commit (use "git add" and/or "git commit -a")
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:


(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .gitignore
modified: pom.xml
Untracked files:
(use "git add <file>..." to include in what will be committed)
Main.js
no changes added to commit (use "git add" and/or "git commit -a")
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git add Main.js
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: Main.js
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .gitignore
modified: pom.xml
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git commit -m "added Main.js"
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"

to set your account's default identity.


Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'cheekati@deepthi.(none)')
git config user.name:-Define author name to be used for all commits in current repo.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git config user.name "chdeepthi6612"
git config user.email:-Define author email to be used for all commits in current repo.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git config user.email "[email protected]"
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git commit -m "added Main.js"
[master 431ec15] added Main.js
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 Main.js
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)

Changes not staged for commit:


(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .gitignore
modified: pom.xml

no changes added to commit (use "git add" and/or "git commit -a")
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git add .
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: .gitignore
modified: pom.xml
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git commit -m "added.gitignore and pom.xml"
[master d1efcf5] added.gitignore and pom.xml
2 files changed, 7 insertions(+), 1 deletion(-)
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
git log –oneline:-print a single commit in a single line as output when the git log command is executed using this option.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git log --oneline
d1efcf5 (HEAD -> master) added.gitignore and pom.xml
431ec15 added Main.js
a24ff53 Add 'post' section with 'junit' steps.
2dc5ed5 Add Jenkinsfile example + wrap wording in README.md
77f2f02 Add README.md content
d84fc5a Initial commit
git branch:-List all of the branches in your repo. Add a argument to create a new branch with the name.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git branch
* master
Git remote:-The git remote command lets you create, view, and delete
connections to other repositories.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git remote
origin
git push:- Push the branch to , along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist.
hp@DESKTOP V04ALOG MINGW64/c/Devops/git /project/simple-java-maven-app (master)
$ git push -u origin master
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 12 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 701 bytes | 701.00 KiB/s, done.
Total 7 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (4/4), completed with 3 local objects.
To https://github.com/chdeepthi6612/simple-java-maven-app.git
1465ed5..d1efcf5 master -> master
branch 'master' set up to track 'origin/master'.

3. Practice Source code management on GitHub. Experiment with


the source code
Program:
mkdir :- It is used to create new directory(or multiple folders)in the file system.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project
$ mkdir demo1
cd :- The cd command, also known as chdir (change directory), is a line shell command used to change the current working directory.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project
$ cd demo1
git init:- Create empty Git repo in specified directory. Run with no arguments to initialize the current directory as a git repository
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project
$ git init
Initialized empty Git repository in C:/DevopsLab/projects/demo1/.git/
ls -a :- This command is used for listing the contents that match the specified file pattern.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ ls -a
./ ../ .git/
git config user.name:-Define author name to be used for all commits in current repo.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git config user.name knavya6624
git config user.email:-Define author email to be used for all commits in current repo
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git config user.email [email protected]
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
mkdir :- It is used to create new directory(or multiple folders)in the file System.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ mkdir src
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
touch command:-It is used to create a file without any content.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ touch src/Main.py
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/
nothing added to commit but untracked files present (use "git add" to track)
touch command:-It is used to create a file without any content.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ touch index.html
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
src/
nothing added to commit but untracked files present (use "git add" to track)
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git add index.html
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/
git rm –cached:-Removes the file only from the Git repository, but not from the filesystem.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git rm --cached index.html
rm 'index.html'
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
src/
nothing added to commit but untracked files present (use "git add" to track)
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git add index.html
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git commit -m "added index.html"
[master (root-commit) 7dd2dae] added index.html
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
git add:-Stage all changes in for the next commit. Replace with a to change a specific file.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git add .
git status:- List which files are staged, unstaged, and untracked.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/Main.py
git commit -m :-Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git commit -m "added Main.py file"
[master 840c954] added Main.py file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 src/Main.py
git branch:-List all of the branches in your repo. Add a argument to create a new branch with the name.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git branch
* master
Git remote:-The git remote command lets you create, view, and delete
connections to other repositories.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git remote
git remote add:-Create a new connection to a remote repo. After adding a remote, you can use as a shortcut for in other commands.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git remote add origin https://github.com/chdeepthi6612/gitcheatsheet.git
Git remote:-The git remote command lets you create, view, and delete
connections to other repositories.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git remote
origin
git push:- Push the branch to , along with necessary commits and objects.
Creates named branch in the remote repo if it doesn’t exist.
hp@DESKTOP V04ALOG MINGW64 /c/Devops/project/demo1 (master)
$ git push -u origin master
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 492 bytes | 492.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/chdeepthi6612/gitcheatsheet.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.

4.Jenkins installation and setup, explore the environment


Aim: Jenkins installation and setup, explore the environment
Jenkins : It is an open source optimization server developer which is used to automate
building,testing and deploying application. It is available in Windows,Linux,Unix and Macos.
Installations:
Step 1 : 1. Browse to the Jenkins download page Under the Downloading Jenkins section is a list of
installers for the long-term support (LTS) version of Jenkins. Click the Windows link to begin the
download.

Step 2 :After Jenkins finishes installing the plugins, enter the required information on the Create
First Admin User page. Click Save andContinue to proceed

Step 3 : On the Instance Configuration page, confirm the port number you want Jenkins to use a nd
click Save and Finish to finish the initial customization

Step 4 : Click the Start using Jenkins button to move to the Jenkins dashboard
Step 5. Using the Jenkins dashboard, click Create a job to build your first
Jenkins software project.

Uing aws :-

 Login to aws,and give your root user emai address and click next.
 opens a AWS home page and click on EC2.
 opens EC2 Dashboard,now launch instance.
Launch an instance and name it as “devopslab”
Select application and OS images “UBUNTU”
Select instance type as t2 micro
Select a key pair (login)
elect network setting and allow all
Now click on devopslab and click connect :

• Connect to instance :
• After connecting the terminal will be open.
• Enter the below commands to install maven ,java ,and Jenkins
• $ sudo apt update
• $ sudo apt install maven -y
• $ sudo apt-get install openjdk-11-jdk -y
•$sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key |

sudo tee/usr/share/keyrings/jenkins-keyring.asc > /dev/null

•$ sudo apt-get install Jenkins

•$ sudo systemctl start jenkins

•$ sudo systemctl status Jenkins

Jenkins has been installled successfully

• Access Jenkins:

 Now, open your web browser and access Jenkins by navigating to:

https://public-ip:8080

 You will see a setup wizard and be prompted to enter the administrator password
XAMPP:

STEP-1:

• Open the xampp and start the Apache, MySQL and tomcat.

• Click on config to modify the servers in this we can see the below options.

➢ Server.xml

➢ Tomcat-user.xml

➢ Web.xml

➢ Content.xml

•Choose the server.xml and modify the port numbers in that server.xml file.

STEP-2:

• Change the server port number as “2025”in the line 22


STEP-3:

• again, change the connector port number as “2020” in the line 69.

STEP-4:

• Open the tomcat-users.xml and add role name and username and set the password as
tomcat.

STEP-5:

• Open “config” and select “service and port settings”.

• We can view a window

• Select tomcat o Change main port as “2025”

• HTTP port as “2020”


• Save the service settings

STEP-6:

• Click on admin button of tomcat, we get Apache tomcat in the browser.

STEP-7:

• After opening Apache tomcat page on local host 2020, select server status.

• Set username and password as “tomcat”

STEP-8:

• Click on manager app and give username and password and sing in.
STEP-9:

• Open manager app and check whether the Jenkins is there or not.

• Click on Jenkins.

Unlock Jenkins:

After completing the installation process, you have to unblock Jenkins before you can
customize and start using it.

Step-1: In your web browser, navigate to the port number you selected during the
installation using the following address:

http://localhost:8080

Step-2: Navigate to the location on your system specified by the Unblock Jenkins page. C:\
ProgramData\Jenkins\.jenkins\secrets\initial admin.
Password

Administrator password:
Step-3: Open the initial Admin Password file using a text editor such as Notepad.

Step 4: Copy the password from the initial Admin Password file. And paste it in the
“administrator password” field on the unblock Jenkins page and click on continue to
proceed.

Customize Jenkins

Once you unlock Jenkins, customize and prepare the Jenkins environment.

Step -1: Click the Install suggested plugins button to have Jenkins automatically install the
most frequently used plugins.

Step-2: After Jenkins finishes installing the plugins, enter the required information on the
Create First Admin User page. Click Save and Continue to proceed.

Step- 3: On the Instance Configuration page, confirm the port number you want Jenkins to
use and click Save and Finish to finish the initial customization.
Step- 4: Click the Start using Jenkins button to move to the Jenkins dashboard.

Step-5:

➢ After Jenkins setup is complete sign in page is opened.

➢ Give the username and password and get sign in to Jenkins.

➢ Jenkins page is opened after sign in.


5. Demonstrate continuous integration and development using
Jenkins.
Aim: Demonstrate continuous integration and development using Jenkins.

DESCRIPTION

Continuous Integration (CI) and Continuous Development (CD) are important practices in
software development that can be achieved using Jenkins. Here's an example of how you can
demonstrate CI/CD using Jenkins:

Create a simple Java application:

• Create a simple Java application that you want to integrate with Jenkins.

• The application should have some basic functionality, such as printing "Hello World" or
performing simple calculations. Commit the code to a Git repository:

• Create a Git repository for the application and commit the code to the repository.

• Make sure that the Git repository is accessible from the Jenkins server.

Create a Jenkins job:

• Log in to the Jenkins web interface and create a new job.

• Configure the job to build the Java application from the Git repository.

• Specify the build triggers, such as building after every commit to the repository.

Build the application:

• Trigger a build of the application using the Jenkins job.

• The build should compile the code, run any tests, and produce an executable jar file.

Monitor the build:

• Monitor the build progress in the Jenkins web interface.

• The build should show the build log, test results, and the status of the build.

Deploy the application:

• If the build is successful, configure the Jenkins job to deploy the application to a production
environment.
• The deployment could be as simple as copying the jar file to a production server or using a
more sophisticated deployment process, such as using a containerization technology like
Docker.

Repeat the process:

• Repeat the process for subsequent changes to the application.

• Jenkins should automatically build and deploy the changes to the production environment.

This is a basic example of how you can use Jenkins to demonstrate CI/CD in software development.
In a real-world scenario, you would likely have more complex requirements, such as multiple
environments, different types of tests, and a more sophisticated deployment process. However, this
example should give you a good starting point for using Jenkins for CI/CD in your software
development projects.

➢ Login to AWS account and open “Jenkins”.

➢ Start the Jenkins instance.

➢ Connect to the Jenkins.

➢ Copy the public IPs address and paste it in the google search with:8080.

➢ Sign in to Jenkins by giving your username and password.

➢ Get sign in to your Jenkins account.

STEP-1:

STEP-2:

➢ Start the instance.


STEP-3:

➢ Login to Jenkins account

STEP-4:

➢ Click on new item In the Jenkins dashboard.

STEP-5:

➢ Enter the project name.

➢ Select freestyle project. ➢ Click on “ok” button.

STEP-6:

➢ Our project is created in Jenkins.

➢ In general, we add the project description as “exploring Jenkins!!!”


STEP-7:

SOURCE CODE MANAGEMENT

➢ In this, we must select the git.

➢ In the git, we must add our git repository URL from our git hub.

➢ Paste this URL in the repository URL.

➢ Add branch specifier column choose “*/master”


STEP-8:

BUILD TRIGGERS

➢ Choose the “build periodically” in build triggers.

➢ In that, fill the 5 stars (* * * * *) in the schedule column in build periodically.

STEP-9: POLL SCM

➢ In poll scm fill 5 stars (* * * * *) In the schedule column.


In the above image “* * * * *” represents:

MINUTE HOUR DOM MONTH DOW

MINUTE: Minutes within the hour (0–59)

HOUR: The hour of the day (0–23)

DOM: The day of the month (1–31)

MONTH: The month (1–12)

DOW: The day of the week (0–7) where 0 and 7 are Sunday

➢In src enabling the git

➢ Click on “Apply” button.

➢ The pop will appear as “saved”

➢commit the changes in the pom.xml file


➢console output

STEP-10:

WEB HOOK:

➢ In build triggers select “GitHub hook trigger for Gitscm polling?”.

➢ Click on “Apply”.

➢ Click on “save”.

➢ Sign in/login to the GitHub account with username /email address and GitHub password.
➢ Now in git-hub Choose “java-hello-world-with-maven” repository.

➢ Click on settings

➢ Click on webhooks

➢ Paste the Jenkins URL in payload URL.

➢ In next step we must choose everything.

➢ This will involve in each, and every event would you like to trigger this webhook.

➢ Select the active radio button to active the webhook

➢ After this, select the button called “add webhook”.

➢ Web hook is created.


commit the changes in the pom.xml file.

console output.

Continuous development

Tomcat installation in AWS

 First login to AWS

 In ec2 dashboard launch instance with instance “QA-AMAZON”


Opens to ec2 console and connect to instance

now open instances

1.click on QA-AMAZON id it opens security groups

2.click on launch wizard link and it opens in edit inbound rules

3.then add rules

Install java: sudo su

sudo yum install java-1.8*

java installation completed

Install Tomcat:

cd /

cd /opt Download tomcat binary:

wget https://archive.apache.org/dist/tomcat/tomcat- 9/v9.0.55/bin/apache-tomcat -


9.0.55.targz
Unzip tomcat binary:

tar -zvfx Apache-tomcat-9.0.55.tar.gz

Add execute permissions to startup and shutdown:

cd apache-tomcat-9.0.55----enters apache-tomcat-9.0.55 folder

cd bin ---enters bin

chmod +x startup.sh

chmod +x shutdown.sh

Create link files for tomcat server up and down:

ln -s /opt/apache-tomcat-9.0.55/bin/startup.sh/ usr/local/bin/tomcatup------creates a


symbolic link

cd

ln -s /opt/apache-tomcat-9.0.55/bin/shutdown.sh/ usr/local/bin/tomcatdown------creates a


symbolic link

tomcat up

Change settings to manage tomcat:

cd .. ------enters to / folder from ~ folder

cd /opt ---enters opt folder

cd apache-tomcat-9.0.55 ---entersapache-tomcat-9.0.55


cd webapps –enters webapps cd host-manager –enters host manager

cd meta-inf enters meta-inf

vi context.xml ---opens an xml code page

Now modify by pressing “I” to insert text –

>! --<valve class Name=”……………..”/>-->

press ecs:wq enter

cd .. –moves from meta inf to host manager

cd .. –moves to webapps

cd manager –moves to manager from webapps

cd meta-inf --moves to meta inf from manage

vi context.xml >! --<valve class Name=”……………..”/>-->


press ecs:wq enter

Update user information in tomcat-users.xml:

cd apache-tomcat-9.0.55 ---enter apache-tomcat-9.0.55 54

cd ..–enters meta-inf cd .. -enters manager

cd ..–enters apache-tomcat-9.0.55 cd conf –enters conf

vi tomcat-users.xml

Adding role names in<tomcat-users> tag:

Access tomcat web interface:

copy public Ip of QA-AMAZON instance and paste it on chrome with :8080

it opens tomcat/9.0.55

now click on manager apps


->by entering name=admin and password=admin to sign and opens tomcat page

Production environment:

• Open aws account and connect Jenkins account

• Open Jenkins interface by using public Ip

•Create a new project as “web-apps” by choosing free style project.

Save it.
• Choose web apps and open it

•install plugins

•plugins are copy artifact, deploy to container and maven integration


• Selects configure and open-source code management

• Add git repository

• Jenkins credential provider

• Build triggers:

• Build steps:

Select invoke top level management and write Goal as: package
• Add post build steps:

Select deploy war/ear to a container

Add **/*.war to it

• Add containers

• Save it and build it

➢ Login to GitHub and open web-apps repository

➢ Open .src/main/web-apps click on it

➢ Open index.jsp file and update it with some code


➢ Now open aws instance and copy the public Ip of tomcat instance 60

➢ Paste it in chrome new tab with 8080 port number

➢ By opening tomcat server select manager app and open it

➢ Now select QA-SSIT and check it

by clicking QA-SSIT the following changes appeared

performing testing

➢copying the URL from GitHub repository


➢opening Jenkins and create a new project called testing

➢open source code management place the URL which is copied from GitHub

➢in branches to build specify master as branch specifier

➢go to build steps select execute shell

➢in execute shell write echo “Testing Pass”

➢check the build history


➢see the console output

➢choose the web app project in Jenkins dashboard

➢open build steps and choose copy artifact from another project

➢apply and save the data

BUILD PERIODICALLY :-

1. Choose Build Triggers and choose Build periodically

2. Add “* * * * * “ to the schedule


In the above image “* * * * *” represents :

MINUTE HOUR DOM MONTH DOW

MINUTE : Minutes within the hour (0–59)

HOUR : The hour of the day (0–23)

DOM : The day of the month (1–31)

MONTH : The month (1–12)

DOW : The day of the week (0–7) where 0 and 7 are Sunday.

POLL SCM :- Click on build triggers and choose poll scm It is similar to build periodically but it will poll our
git hub repository whenever there is a commit in repository it detect the change in that period or schedule
EXPERIMENT NO: 6. Explore Docker commands for content management.
AIM: Explore Docker commands for content management.

DESCRIPTION: Docker is a containerization technology that is widely used for managing application
containers. Here are some commonly used Docker commands for content management.

•Install Docker:

• Install all required dependency packages

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common –y

• Add the Docker GPG key to your server's keyring.

$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc

• Add the latest Docker repository to your APT sources.

$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc]


https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee
/etc/apt/sources. List. d/docker. List > /dev/null

• Update the server package index.

$ sudo apt update

Install Docker.

$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin


• View the installed Docker version on your server.

$ sudo docker –version

Manage the Docker System Service

• Enable the Docker system service to start automatically at boot time.

$ sudo systemctl enable docker

• View the Docker service status and verify that it's running.

$ sudo systemctl status docker

$ sudo systemctl status docker

• getting to root user i.e. sudo su –

• docker run-specify an image reference to create the container form

• Docker PS-provide the list of docker containers on our machines


• docker PS -a-list all containers regardless of their state (running, stopped, exited)

• docker PS -a -q-list the id of all docker container on our system including running, stopped and exited
containers

 Docker images:- will return the list of all images in it

 Here 8081 will specify the host IP and 8080(AWS) port reprents the local host IP(local Machine)

 docker pull-download a docker image from a registry, such as docker hub, to our machine

Editing inbound rules:


• docker pull-download a docker image from a registry, such as docker hub, to our machine

 Docker image

• opening Jenkins from docker through public id of docker 8081:8080


• make directory(mkdir)-DockerImages

• change directory(cd)-DockerImages

• make directory-MyFirstImage • change directory-MyFirstImage

• opening vi editor-vi Dockerfile

• place the content in the vi editor

• ls-listing all the directories

• docker build -t myfirst -build a docker image from a docker file and tag the image with myfirst

• docker build -t myfirst:0.1

.  Docker build-command to build a docker image

 -t myfirst:0.1-tags the image with the name myfirst and the tag 0.1

’.’-docker file is in current directory

• cat dockerfile-used to display the content of the dockerfile

• docker run -used to create and start a new container from a specified docker image
• vi dockerfile-opening vi editor in the name of dockerfile

• place the content in the vi editor as displays in the image

• cat command

• docker run

• -d ----starting the container in a detached mode


• making directory-3.0

• change directory-3.0

• opening vi editor

• placing the content when vi editor is open

•docker build -t command used to build a docker image with name myfirst and tag 0.3 with current
directory ‘.’.

• docker run used to create and start a new container from the docker image tagged ‘myfirst’ with
version 0.3
EXPERIMENT-7: -DEVELOP A SIMPLE CONTAINERIZED APPLICATION USING DOCKER

Aim: -To develop a containerized application using docker

sudo su -:-switch the current user to root use

ls -list all the files

git clone -cloning the git repository

cd -changing directory i.e., web-app

installing maven

mvn package-build automation tool for java projects it does validate, compile, test, package

changing the directory to target folder


cpweb-app.war /root/--cp (copy cmd),

web-app.war (source file to be copied),

/root/ (destination directory where the file is copied)

opening vi editor in the name of Dockerfile

docker build (build docker image) -t webapp (tags the image name as webapp and tag is 0.1):0.1 .
(.indicates current directory)

editing inbound rules as port range to 2020

open the docker page with publicid:2020/webapp


EXPERIMENT-8: -INTEGRATE KUBERMETES WITH DOCKER

Aim-Integrating kubermetes with docker.

Step-1:

Installing docker desktop

selecting the configuration

close and restart the system to start the docker system

setting the docker desktop

continue without signing in to see the docker engine start page


docker engine has started

Step-2: - Installing kubermetes

agree all the conditions and set a path or consider default location to install kubermetes.
Step-3: -

opening windows power shell or gitbash start the minikube.

the minikube container will appear on the docker desktop page.

cloning the GitHub repo and updating the branch


STUDENT@SAIS-LAB02-24 MINGW64 ~ (master)
$ git clone https://github.com/Iliyaz-Syed/k8s-main.git
Cloning into 'k8s-main'...
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 29 (delta 15), reused 13 (delta 5), pack-reused 0
Receiving objects: 100% (29/29), 6.52 KiB | 6.52 MiB/s, done.
Resolving deltas: 100% (15/15), done.

changing directory to k8s-demo

eval –evaluate an expression that results in str or number.

kubectl get svc – used to list all the services in a kubermetes cluster

docker build -t fimage: latest .

Docker build -build a docker image

fimage: latest-image with name fimage and tag latest .

- current working directory

kubectl apply -f flask-app-deployment.yml – used to apply the configuration specified in the flask-
app deployment.yml file your kubermetes cluster.
kubectl get services-list all the services in kubermetes cluster.

minikube tunnel- creates a network route, assign external ips

copy the external ip:6006 run it in the browser. 80

viewing the output through the browser


EXPERIMENT-9: XPATH PROGRAM

Aim: -To perform a xpath operation a web application

Program: -

package com.flipkart;

import java.util.List;

import org.openqa.selenium.By;

import org.openqa.selenium.JavascriptExecutor;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

//import org.openqa.selenium.support.ui.ExpectedConditions;

//import org.openqa.selenium.support.ui.WebDriverWait;

import io.github.bonigarcia.wdm.WebDriverManager;

public class flipkart {

private static WebDriver driver;

public static void main(String[] args) {

WebDriverManager.chromedriver().setup();

driver = new ChromeDriver();

driver.manage().window().maximize();

// chapter2();

// chapter3();

// chapter4();

// chapter5();

// chapter6();

// chapter7();
// chapter8();

// chapter9();

public static void highlight(WebElement element) {

JavascriptExecutorjsExecutor = (JavascriptExecutor) driver;


jsExecutor.executeScript("arguments[0].setAttribute('style', 'border:2px solid red;
background:yellow')", element);

// Types of XPath public static void chapter2() {

driver.get("https://www.flipkart.com/");

// Wait until the element is clickable // WebDriverWait wait = new WebDriverWait(driver, 10);

//WebElementmobilesLink=wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//
a[@aria-label='Mobiles']")));

highlight(driver.findElement(By.xpath("//*[@id=\"container\"]/div/div[1]/div/div/div/div/div[1]/
div/div/div/div[2]/div[1]/div/div[1]/ div/div/div/div/div[1]/a[3]/div/div/div/div/img")));

// Additional code to interact with the next page can be added here

// XPath using Attributes

public static void chapter3() {

driver.get("https://www.flipkart.com/");

WebElementloginButton=driver.findElement(By.xpath("//*[@id=\"container\"]/div/div[1]/div/div/
div/div/div[1]/div/div/div/div[2]/div[1]/div/div[1]/div/div/di v/div/div[1]/a[4]/div/div/div/div"));
highlight(loginButton); loginButton.click();

// Additional code to interact with the login page can be added here

// XPath Operatorspublic static void chapter4() {

driver.get("https://www.flipkart.com/");

List elements = driver.findElements(By.xpath("//div[contains(@class,'_1AtVbE')]"));


for (WebElement element : elements) {

83 highlight(element);

// XPath Conditions

public static void chapter5() {

driver.get("https://www.flipkart.com/");

List elements = driver.findElements(By.xpath("//div[@class='_2kHMtA' and


contains(.,'Samsung')]"));

for (WebElement element : elements) {

highlight(element);

// XPath with Index

public static void chapter6() {

driver.get("https://www.flipkart.com/");
highlight(driver.findElement(By.xpath("(//div[@class='_1AtVbE'])[2]")));

// XPath Functions

public static void chapter7() {

driver.get("https://www.flipkart.com/");
highlight(driver.findElement(By.xpath("//span[text()='Cart']")));
highlight(driver.findElement(By.xpath("//a[contains(text(),'Top Offers')]")));
highlight(driver.findElement(By.xpath("//div[contains(@class,'_1YokD2')]")));
highlight(driver.findElement(By.xpath("//a[starts-with(text(),'Grocery')]")));
highlight(driver.findElement(By.xpath("//div[normalize-space(text())='Electronics']")));
System.out.println(driver.findElements(By.xpath("(//div[@class='_1AtVbE'])[position()>2]")).size());

// XPath Axes

public static void chapter8() {


driver.get("https://www.flipkart.com/");

84 highlight(driver.findElement(By.xpath("//a[text()='Login']/preceding-sibling::div")));
highlight(driver.findElement(By.xpath("//div[text()='Mobiles']/following::div[1]"))); }

// XPath Shortcuts

public static void chapter9() {

driver.get("https://www.flipkart.com/");

// text() -> . highlight(driver.findElement(By.xpath("//span[.='Cart']")));


highlight(driver.findElement(By.xpath("//a[contains(.,'Offers')]")));
highlight(driver.findElement(By.xpath("//div[starts-with(.,'Electronics')]")));
highlight(driver.findElement(By.xpath("//div[normalize-space(.)='Mobiles']")));

// child -> / highlight(driver.findElement(By.xpath("//div[@class='_1YokD2']/div")));

// parent -> /.. highlight(driver.findElement(By.xpath("//span[.='Cart']/..")));

// descendant -> // List elements = driver.findElements(By.xpath("//div[@class='_1YokD2']//div"));


for (WebElement element : elements) { highlight(element);

Output:
EXPERIMENT-10: Install and Explore Selenium for automated testing.

Selenium:

Selenium is a free, open-source automation testing suite for web applications across different
browsers and platforms. It is somewhat like HP Quick Test Pro (QTP, currently UFT). However,
Selenium focuses on automating web-based applications.

Steps:  Open chrome and search for “selenium.dev” open selenium automated browse

 Click on downloads and select java for selenium client and WebDriver language binding

 Selenium server (Grid)

• Download latest stable version 4-22.0

 Selenium IDE:

at selenium ide click chrome link

it opens selenium ide, now click on add to chrome

click on extensions and select selenium and pin it


click on selenium ide and select record a new test in a new project

name your project and click ok and save your project base URL

click on start recording

open ssit-demo page and browse it check and test cases

now check the recording in the ssit-demo project page

and save it as new test as ssit


Output:

Selenium Environment Setup:

Installing Selenium requires going through the following steps:

Step 1: Install Java Before moving further download and install Java Software Development Kit (JDK)
in the first place.

Step 2: Install Eclipse IDE Next, download and install Eclipse IDE for Java developers keeping in mind
the 32 or 64-bit windows versions.

After completing the installation of eclipse open eclipse

Create a new maven Project

Click on the File menu, then go to New and select maven Project select maven project name and
location
Select an archetype,by using maven-archetype-qickstart-1.4

Set archetype parameters and finish it

• Open pom.xml file from eclipse page itself by using file tab

• Now open chrome and search for maven repository

• Search for selenium and WebDriver manager maven repository

• Selenium dependency:

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->


<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.22.0</version>
</dependency>
•WEBDRIVERMANAGER dependency:
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.9.1</version>
</dependency>
• Copy both above dependency and paste it on pom.xml file in dependencies tag
• Run it as maven test Run it as maven test
checking the build success
creating a new class file

enabling public static void main in method stubs


naming the class name as: TestLibraries

now open the package explorer and select saispurthi file


testing code for automated testing:
Code:
Save the code and run it
Output:

Dropdown Testing:

again, open the package explorer and select saispurthi file

creating a new class file

enabling public static void main in method stubs

naming the class name as: DropDown

Code:
Output:
EXPERIMENT-11: write a simple program in JavaScript and perform testing
using selenium.

JMeter is an open-source testing tool that analyses and measures the performance of software and
products. The tool is entirely Java-based and ensures performance testing, load testing, and
functional testing.

Earlier, JMeter was originally developed for web applications but has now expanded to several other
functions.

Steps to install JMeter:

1.Check if Java Is Installed

• Open the command prompt

• Put the command java –version

2. Download JMeter
• To download JMeter go to the Apache JMeter website
https://jmeter.apache.org/download_jmeter.cgi
• On the website go to the binaries section and download the zip file
• Wait for the zip folder to be downloaded

3. Install JMeter
• Once the zip folder is downloaded, go to the folder location, and then extract the zip
folder
• After completing the extraction open bin file then apacheJmeter.jar

•Start the process.

• After we must create a folder with the name “Sonar”, again in that we have to create another
folder called “JMeter-demo”.

•After that we must open it with git bash.

•For the continuation of the next process here, we must install “node js”.

•After that extract the node js also.

•createa folder in apache-jmeter-5.6.3 in that create a new folder called sonar

•in sonar folder create a new folder called JMeter-demo


For automated testing we must install some dependencies in the JMeter-demo folder via gitbash.

•initialising empty npm repository in gitbash

•list the files and directories-ls

•installing selenium WebDriver

•displaying the content of the files-cat


•installing chrome driver

•ls

•cat command

•installing gecko driver

•cat command

•open bin file in JMeter-folder


•from that bin folder open Apache-JMeter and select all the options displaying in the image

•viewing the results in the tree

•viewing the results in the table


•selecting JMeter-demo andJMeter-Gui-demo

•setting the file name

•then select the http request

•in http request place the server’s name or Ipas saispurthi.ac.in and path as csefaculty.php

•viewing the results in tree


•viewing the results in table

•After completing above installation process in the google Test directory we create a folder “Test” in
that we must create a test document with the name “gwsTest.js”

•After that go to VISUAL STUDIO Code, and then open it with the test document and in that we
must write the code for the automated testing

• Code:

const {By, Key, Builder} = require("selenium-WebDriver");

require("chromedriver");

async function example () {

var searchString = "Automation testing with Selenium";

//To wait for browser to build and launch properly

let driver = await new Builder (). for Browser("chrome"). build ();

//To fetch http://google.com from the browser with our code.


await driver. Get("http://google.com"); //

To send a search query by passing the value in searchString.

await driver. findElement (By.name("q")). sendKeys (searchString, Key. RETURN);

//Verify the page title and print it

var title = await driver. getTitle ();

console.log ('Title is:’, title);

//It is always a safe practice to quit the browser after execution

await driver. Quit ();

Output:
EXPERIMENT-12: Develop the test cases for the above containerized
application using selenium

➢ Testing the code for highlighting the specific fields:

CODE:-

package csm. Testselinium:

import org. openqa. selenium. By; import org. openqa. selenium. JavascriptExecutor:

import org. openqa. selenium. WebDriver; import org. openqa. selenium. WebElement;

import org. openqa. selenium. chrome.ChromeDriver;

import io.github.bonigarcia.wdm. WebDriverManager;

public class TestLib (public static void main (String [] args) throws InterruptedException {

// TODO Auto-generated method stub WebDriverManager. Chromedriver (); setup ();

WebDriver driver = new ChromeDriver ();

driver. Get("https://github.com/login");

Thread. Sleep (3000);

highlight (driver, driver. FindElement (By.id ("login field")));

Thread. Sleep (3000);

highlight (driver, driver. FindElement (By.name("password")));

Thread. Sleep (3000);


highlight (driver, driver. FindElement (By. className("header-logo")));

Thread. Sleep (3000);

highlight (driver, driver. FindElement (By. linkText ("Forgot password?")));

Thread. Sleep (3000);

highlight (driver, driver. FindElement (By. partialLinkText ("Create an")));

Thread. Sleep (3000);

highlight (driver, driver. FindElement (By. tagname("h1")));

Thread. Sleep (3000); highlight (driver, driver. FindElement (By. xpath ("//label [contains (text
(),'Username or email address')]")));

Thread. Sleep (3000);

highlight (driver, driver. FindElement (By. cssSelector("input[name='commit']")));

public static void highlight (WebDriver driver, WebElement element) {JavascriptExecutor jsExecutor
= (JavascriptExecutor) driver;

jsExecutor.executeScript("arguments [0]. setAttribute ('style', 'border:2px solid red; background:


yellow')", element);

Save the code and run the output:


EXPERIMENT-13: INSTALLATION OF SONARQUBE

SonarQube is a self-managed, automatic code review tool that systematically helps you deliver
Clean Code.

As a core element of our Sonar solution. SonarQube integrates into your existing workflow and
detects issues in your code to help you perform continuous code inspections of your projects.
Installation for SonarQube in aws: -

Step 1:
• open AWS account, Launch an instance

• create instance name as SonarQube

Step 2: connect the instance to server

Step 3:

• start the SonarQube instance and set the port number

• Select EDIT INBOUND RULE

• Add a new rule by adding “9000” port number to it and save

Steps to install and configure SonarQube:

Install java 17:

--> sudo apt install openjdk-17-jdk

Verifying the java version:


Install unzip:

--> sudo apt install unzip

Download and initialise sonarqube:


wgethttps://binaries.sonarsource.com/Distribution/sonarqube/sonarqube- 10.6.0.92116.zip

Unzip SonarQube:

--> unzip sonarqube 10.6.0.92116.zip

Move to sonarqube:

-->cd sonarqube-10.6.0.92116.zip

Move to bin:

--> cd bin/

Select operating system to run SonarQube:

--> cd linux-x86-64/

Select sonar:
--> ./sonar.sh

Start sonarqube:

- >./sonar.sh start

Open console:

-->./sonar.sh console

access sonarqube interface:

http:// public Ip: 9000 /

You can see sonarqube page

sonarqube login page:

username: admin

password: admin

* Sonarqube has been created

Updating old password:


SonarQube integration with Jenkins

Step1: -

1.open SonarQube and now create a local project by clicking on create project select (use the global
setting) and create project

2.generate a SonarQube authentication token

3.analyze your project


Step-2: -

1.go to the Jenkins dashboard: open your Jenkins in a web browser

2.click on “manage Jenkins”: this will take you to Jenkins management page

3.click on “plugins”: navigate to plugin management section

4.go to “available plugins” search for SonarQube scanner plugin

5.restart Jenkins if required

Step-3: -

1.click on “manage Jenkins”: this will take you to the Jenkins management page
2.click on “credentials”: navigate to the credentials

3.scroll down to the “stores scoped to Jenkins” section: here click on global

4.click on “add credentials”: here you can add the id of the token you have generated

5.click on tools
6. Scroll down to the "SonarQube scanner installations": Fill the name with installed plugin name i.e.,
SonarQube and select the specific version of the plugin then click on ‘Save’.

Configure SonarQube Scanner:

1. Go to the Jenkins Dashboard: Open your Jenkins instance.

2. Click on "Manage Jenkins": This will take you to the Jenkins management page

3.Click on "System":
4. Scroll down to the "SonarQube Server" section: Fill the details and save.

Step 4:
Create a Jenkins Pipeline for SonarQube Analysis
Create a New Pipeline Job:
Go to the Jenkins Dashboard: Open your Jenkins instance.
Click "New Item": Create a new Jenkins item.
Enter a name for your job and select "Pipeline": Provide a name for your pipeline job and
select the pipeline option.

Configure the Pipeline Script:

1.In the pipeline configuration page, scroll down to the "Pipeline" section: Configure the pipeline
script.
2. Select "Pipeline script" and enter your pipeline script: Use the following example script:

pipeline {

agent any

stages {

stage ('Fetch Code') {

steps {

git https://github.com/harsha5969/web-app

}}

stage ('Code Analysis') {

environment {

scannerHome = tool name: 'Sonarqube', type:

'hudson. plugins. sonar. SonarRunnerInstallation’

steps {

script {

withSonarQubeEnv('Sonar') {

sh """

${scannerHome}/bin/sonar-scanner \

-Dsonar.projectKey=test-sonar \

-Dsonar.projectName=test-sonar \

-Dsonar.projectVersion=1.0 \

-Dsonar.sources=. “””

}}}}}}

Step 5:

Run the Jenkins Job Build the Pipeline:


1. Save the pipeline configuration: Ensure your configurations are saved.

2. Click "Build Now" to run the pipeline: Start the pipeline job.

3. Monitor the build log to ensure the SonarQube analysis runs successfully: Check the build logs to
confirm successful execution.

You might also like