Department of Computer Science and Engineering (AI & ML) : Sai Spurthi Institute of Technology
Department of Computer Science and Engineering (AI & ML) : Sai Spurthi Institute of Technology
DEVOPS LAB
MANUAL
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'.
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/
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'.
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'.
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'.
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 |
• 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:
• 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:
STEP-6:
STEP-7:
• After opening Apache tomcat page on local host 2020, select server status.
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:
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 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.
• 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.
• The build should compile the code, run any tests, and produce an executable jar file.
• The build should show the build log, test results, and the status of the build.
• 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.
• 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.
➢ Copy the public IPs address and paste it in the google search with:8080.
STEP-1:
STEP-2:
STEP-4:
STEP-5:
STEP-6:
➢ In the git, we must add our git repository URL from our git hub.
BUILD TRIGGERS
DOW: The day of the week (0–7) where 0 and 7 are Sunday
STEP-10:
WEB HOOK:
➢ 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
➢ This will involve in each, and every event would you like to trigger this webhook.
console output.
Continuous development
Install Tomcat:
cd /
chmod +x startup.sh
chmod +x shutdown.sh
cd
tomcat up
vi tomcat-users.xml
Production environment:
Save it.
• Choose web apps and open it
•install plugins
• Build triggers:
• Build steps:
Select invoke top level management and write Goal as: package
• Add post build steps:
Add **/*.war to it
• Add containers
performing testing
➢open source code management place the URL which is copied from GitHub
➢open build steps and choose copy artifact from another project
BUILD PERIODICALLY :-
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 Docker.
• View the Docker service status and verify that it's running.
• docker PS -a -q-list the id of all docker container on our system including running, stopped and exited
containers
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
Docker image
• change directory(cd)-DockerImages
• docker build -t myfirst -build a docker image from a docker file and tag the image with myfirst
-t myfirst:0.1-tags the image with the name myfirst and the tag 0.1
• 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
• cat command
• docker run
• change directory-3.0
• opening vi editor
•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
installing maven
mvn package-build automation tool for java projects it does validate, compile, test, package
docker build (build docker image) -t webapp (tags the image name as webapp and tag is 0.1):0.1 .
(.indicates current directory)
Step-1:
agree all the conditions and set a path or consider default location to install kubermetes.
Step-3: -
kubectl get svc – used to list all the services in a kubermetes cluster
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.
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;
WebDriverManager.chromedriver().setup();
driver.manage().window().maximize();
// chapter2();
// chapter3();
// chapter4();
// chapter5();
// chapter6();
// chapter7();
// chapter8();
// chapter9();
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
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
driver.get("https://www.flipkart.com/");
83 highlight(element);
// XPath Conditions
driver.get("https://www.flipkart.com/");
highlight(element);
driver.get("https://www.flipkart.com/");
highlight(driver.findElement(By.xpath("(//div[@class='_1AtVbE'])[2]")));
// XPath Functions
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
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
driver.get("https://www.flipkart.com/");
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 IDE:
name your project and click ok and save your project base URL
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.
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
• Open pom.xml file from eclipse page itself by using file tab
• Selenium dependency:
Dropdown Testing:
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.
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
• After we must create a folder with the name “Sonar”, again in that we have to create another
folder called “JMeter-demo”.
•For the continuation of the next process here, we must install “node js”.
•ls
•cat command
•cat command
•in http request place the server’s name or Ipas saispurthi.ac.in and path as csefaculty.php
•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:
require("chromedriver");
let driver = await new Builder (). for Browser("chrome"). build ();
Output:
EXPERIMENT-12: Develop the test cases for the above containerized
application using selenium
CODE:-
import org. openqa. selenium. By; import org. openqa. selenium. JavascriptExecutor:
import org. openqa. selenium. WebDriver; import org. openqa. selenium. WebElement;
public class TestLib (public static void main (String [] args) throws InterruptedException {
driver. Get("https://github.com/login");
Thread. Sleep (3000); highlight (driver, driver. FindElement (By. xpath ("//label [contains (text
(),'Username or email address')]")));
public static void highlight (WebDriver driver, WebElement element) {JavascriptExecutor jsExecutor
= (JavascriptExecutor) driver;
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
Step 3:
Unzip SonarQube:
Move to sonarqube:
-->cd sonarqube-10.6.0.92116.zip
Move to bin:
--> cd bin/
--> cd linux-x86-64/
Select sonar:
--> ./sonar.sh
Start sonarqube:
- >./sonar.sh start
Open console:
-->./sonar.sh console
username: admin
password: admin
Step1: -
1.open SonarQube and now create a local project by clicking on create project select (use the global
setting) and create project
2.click on “manage Jenkins”: this will take you to Jenkins management page
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’.
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.
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 {
steps {
git https://github.com/harsha5969/web-app
}}
environment {
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:
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.