0% found this document useful (0 votes)
25 views45 pages

SDT Lab Manual

The document is a Software Development Lab Manual that provides detailed procedures for deploying a Version Control System using Git, performing various Git operations, and setting up Continuous Integration with Jenkins. It includes step-by-step instructions for installing Git, configuring GitHub credentials, and executing tests with Jenkins using Maven. Additionally, it covers Tomcat server configuration and creating a pipeline for deploying applications.

Uploaded by

ramyamjy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views45 pages

SDT Lab Manual

The document is a Software Development Lab Manual that provides detailed procedures for deploying a Version Control System using Git, performing various Git operations, and setting up Continuous Integration with Jenkins. It includes step-by-step instructions for installing Git, configuring GitHub credentials, and executing tests with Jenkins using Maven. Additionally, it covers Tomcat server configuration and creating a pipeline for deploying applications.

Uploaded by

ramyamjy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Software Development lab Manual

Exercise 1 : Write a procedure to Deploy Version Control System / Source Code Management, install git and
create a GitHub account.

Aim:

Procedure:

Steps For Git Installation on Windows

1. Download and install Git

2. Git bash interface

3. Basic Git commands

4. Create a local repository

5. Connect to the remote repository

6. Push the file to GitHub

Step 1:

Download the latest version of Git and choose the 64/32 bit version. After the file is downloaded, install it in
the system. Once installed, select Launch the Git Bash, then click on finish. The Git Bash is now launched.
Software Development lab Manual

Step 2:

Check the Git version:

$ git --version

Step 3:

For any help, use the following command:

$ git help config

This command will lead you to a browser of config commands. Basically, the help the command provides a
manual from the help page for the command just following it (here, it's config).

Another way to use the same command is as follows:

$ git config --help

Step 4:

Create a local directory using the following command:

$ mkdir test

$ cd test

Step 5:

The next step is to initialize the directory:

$ git init
Software Development lab Manual

Step 6:

Go to the folder where “test” is created and create a text document named “demo.” Open “demo” and put
any content, like “Hello MCA.” Save and close the file.

Step 7:

Enter the Git bash interface and type in the following command to check the status:

$ git status

Step 8:

Add the “demo” to the current directory using the following command:

$ git add demo.txt

Step 9:

Next, make a commit using the following command:

$ git commit -m “committing a text file”

Step 10:

Link the Git to a Github Account:

$ git config --global user.username

Note: simplilearn-github is the username on the Github account.

Step 11:

Open your Github account and create a new repository with the name "test_demo" and click on "Create
repository." This is the remote repository. Next, copy the link of "test_demo."
Software Development lab Manual

Step 12:

Go back to Git bash and link the remote and local repository using the following command:

$ git remote add origin <link>

Here, <link> is the link copied in the previous step.

Step 13:

Push the local file onto the remote repository using the following command:

$ git push origin master

Step 14:

Move back to Github and click on "test_demo" and check if the local file "demo.txt" is pushed to this
repository.

1. There are some experimental options available such as pseudo control Support or Built in file system
monitor concerning your installed Git version.

How to Launch Git in Windows?

There are two methods to launch git in windows. One is launching git using a bash scripting shell with the
help of the command line and another is launching git using a graphical user interface.

1. To launch git via bash scripting shell,


First, open the window and search for git bash and open it.

2. To launch git via graphical user interface(GUI), similarly, first open the window and search for git
GUI and click on the application icon and open it.
Software Development lab Manual

Configure GitHub Credentials

You can configure your local GitHub installation with credentials by using the following commands. Also,
don't forget to add your own GitHub credentials for username and email address.

1. git config –global user.n


ame "github_username"

2. git config –global user.e


mail "email_address"

Clone a GitHub Repository

1. Initially you need to click the options repository on GitHub.

2. Then in the top right corner, click the option clone or download where a small drop-down box will
appear having a URL for cloning over HTTPS.

3. Then enter into your Powershell windows and write clone URL as:
git clone repository_url

4. On the other hand, you can clone a github repository with SSH URLs where first you need to generate
an SSH key pair on your windows workstation as well as need to assign a public key to your GitHub account.

List Remote Repositories

1. Make a copy of the repository from GitHub for your working directory.

2. Ensure that the working directory should have the project name as
"cd git_project" and replace the project name from the downloaded repository.

3. If the above option doesn't work, you can list the content using "ls command" for the current directory,
especially to check your exact number of spellings.

4. Besides, you can list the remote repository in the sub-directory as "git remote -v".

Output:

—---------------------------------------------------------------------------------------------

Exercise 2: Write a procedure to perform various GIT operations on local and Remote repositories using
GIT Cheat-Sheet
Software Development lab Manual

Aim:

Procedure:
1. Git configuration
● Git config
Get and set configuration variables that control all facets of how Git looks and operates.
Set the name:
$ git config --global user.name "User name"
Set the email:
$ git config --global user.email "[email protected]"
Set the default editor:
$ git config --global core.editor Vim
Check the setting:
$ git config -list
● Git alias
Set up an alias for each command:
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
2. Starting a project
● Git init
Create a local repository:
$ git init
● Git clone
Make a local copy of the server repository.
$ git clone
3. Local changes
● Git add
Add a file to staging (Index) area:
$ git add Filename
Software Development lab Manual

Add all files of a repo to staging (Index) area:


$ git add*
● Git commit
Record or snapshots the file permanently in the version history with a message.
$ git commit -m " Commit Message"
4. Track changes
● Git diff
Track the changes that have not been staged: $ git diff
Track the changes that have staged but not committed:
$ git diff --staged
Track the changes after committing a file:
$ git diff HEAD
Track the changes between two commits:
$ git diff Git Diff Branches:
$ git diff < branch 2>
● Git status
Display the state of the working directory and the staging area.
$ git status
● Git show Shows objects:
$ git show
5. Commit History
● Git log
Display the most recent commits and the status of the head:
$ git log
Display the output as one commit per line:
$ git log -oneline
Displays the files that have been modified:
$ git log -stat
Display the modified files with location:
$ git log -p
Software Development lab Manual

● Git blame
Display the modification on each line of a file:
$ git blame <file name>
6. Ignoring files
● .gitignore
Specify intentionally untracked files that Git should ignore. Create .gitignore:
$ touch .gitignore List the ignored files:
$ git ls-files -i --exclude-standard
7. Branching
● Git branch Create branch:
$ git branch List Branch:
$ git branch --list Delete a Branch:
$ git branch -d Delete a remote Branch:
$ git push origin -delete Rename Branch:
$ git branch -m
● Git checkout
Switch between branches in a repository.
Switch to a particular branch:
$ git checkout
Create a new branch and switch to it:
$ git checkout -b Checkout a Remote branch:
$ git checkout
● Git stash
Switch branches without committing the current branch. Stash current work:
$ git stash
Saving stashes with a message:
$ git stash save ""
Check the stored stashes:
$ git stash list
Re-apply the changes that you just stashed:
Software Development lab Manual

$ git stash apply


Track the stashes and their changes:
$ git stash show
Re-apply the previous commits:
$ git stash pop
Delete a most recent stash from the queue:
$ git stash drop
Delete all the available stashes at once:
$ git stash clear
Stash work on a separate branch:
$ git stash branch
● Git cherry pic
Apply the changes introduced by some existing commit:
$ git cherry-pick
8. Merging
● Git merge
Merge the branches:
$ git merge
Merge the specified commit to currently active branch:
$ git merge
● Git rebase
Apply a sequence of commits from distinct branches into a final commit.
$ git rebase
Continue the rebasing process:
$ git rebase -continue Abort the rebasing process:
$ git rebase --skip
● Git interactive rebase
Allow various operations like edit, rewrite, reorder, and more on existing commits.
$ git rebase -i
9. Remote
Software Development lab Manual

● Git remote
Check the configuration of the remote server:
$ git remote -v
Add a remote for the repository:
$ git remote add Fetch the data from the remote server:
$ git fetch
Remove a remote connection from the repository:
$ git remote rm
Rename remote server:
$ git remote rename
Show additional information about a particular remote:
$ git remote show
Change remote:
$ git remote set-url
● Git origin master
Push data to the remote server:
$ git push origin master Pull data from remote server:
$ git pull origin master
10. Pushing Updates
● Git push
Transfer the commits from your local repository to a remote server. Push data to the remote server:
$ git push origin master Force push data:
$ git push -f
Delete a remote branch by push command:
$ git push origin -delete edited
11. Pulling updates
● Git pull
Pull the data from the server:
$ git pull origin master
Software Development lab Manual

Pull a remote branch:


$ git pull
● Git fetch
Download branches and tags from one or more repositories. Fetch the remote repository:
$ git fetch< repository Url> Fetch a specific branch:
$ git fetch
Fetch all the branches simultaneously:
$ git fetch -all
Synchronize the local repository:
$ git fetch origin
12. Undo changes
● Git revert
Undo the changes:
$ git revert
Revert a particular commit:
$ git revert
● Git reset
Reset the changes:
$ git reset -hard
$ git reset -soft:
$ git reset --mixed
13. Removing files
● Git rm
Remove the files from the working tree and from the index:
$ git rm <file Name>
Remove files from the Git But keep the files in your local repository:
$ git rm –cached

Output:

—---------------------------------------------------------------------------------------------
Software Development lab Manual

Exercise 3
Continuous Integration: install and configure Jenkins with Maven/Ant/Gradle to setup a
build Job.

Aim:

Procedure:

1. Prerequisite
2. Implementation Steps
1. Create a project for running the tests using Selenium WebDriver and TestNG
2. Create the Test Code
3. Start the Jenkins server
4. Log in to Jenkins UI
5. Download and Install Maven Plugin
6. Add the Maven Integration plugin
7. Restart Jenkins
8. Create a new project using the Maven project plugin
9. Build Management
10.Execute the tests

3. Implementation Steps
Step 1: Create a project for running the tests using Selenium WebDriver and TestNG
Step 2: Create the Test Code
You can refer to this tutorial to get the test code – Integration Of Jenkins With Selenium
WebDriver.

Step 3: Start the Jenkins server


Open the browser and navigate to the localhost and the port in which Jenkins is running.
http://localhost:8080/

Step 4: Log in to Jenkins UI


Provide username and password and click on Sign in.

Step 5: Download and Install Maven Plugin


Click on the Manage Jenkins.

Choose Manage Plugins.


Software Development lab Manual

Step 6: Add the Maven Integration plugin


On the Plugins Page, go to the Available option
1. Select the Maven Integration Plugin
2. Click on Install without restart. The plugin will take a few moments to finish downloading
depending on your internet connection, and will be installed automatically.
3. You can also select the option Download now and Install after the restart button. In which
plugin is installed after the restart
4. You will be shown a “No updates available” message if you already have the Maven plugin
installed.

The plugin “Maven Integration” has been installed successfully.

Step 7: Restart Jenkins


Click on the checkbox “Restart Jenkins when installation is complete when no jobs are
running“.

The Jenkins is being restarted, It is about to restart. Again, log in to Jenkins UI.

Step 8: Create a new project using the Maven project plugin


1. Give the Name of the project.
2. Click on the Maven project.
3. Click on the OK button.

In the General section, enter the project description in the Description box.

Step 9: Build Management

Go to the Build section of the new job.


§ In the Root POM textbox, enter the full path to pom.xml
§ In the Goals and options section, enter “clean test”
Click on Apply and Save buttons.

We have created a new Maven project “SeleniumTestNG_MavenDemo” with the configuration to


run the Selenium with TestNG Tests

Step 10: Execute the tests


Click on the Build Now link. Maven will build the project. It will then have TestNG execute the
test cases.
To see the current status of the execution, click on the “console output“.

OUTPUT:
Software Development lab Manual

—---------------------------------------------------------------------------------------------

Exercise 4:
Build the pipeline of jobs using Maven / Gradle / Ant in Jenkins, create a pipeline script to
Test and deploy an application over the tomcat server.

AIM:

Procedure:
● Tomcat Configuration
o Environment Configuration
o Update Roles and User credentials - Configuring Tomcat Security

● Jenkins Configuration
o Step1: Make Sure you have Git and Maven installed
o Step2: Install Deploy to Container Plugin.
o Step3: Create and Configure a Maven Job with Source Code Management (Github)
o Step4: Configure the Post-build Action and Specify the Tomcat Server Details
o Build Jenkins Job
o Testing the Application

Tomcat Configuration
· We presume that you have downloaded and started the tomcat server with no issues. Now we
will advance to the next level which is making Tomcat ready to receive deployments and enabling
TEXT based and GUI based management interface.

· All the tomcat application servers come with the manager application by default. If you look
at the webapps directory of your downloaded tomcat server. You can see it.

· At the first time, you may not be able to access it cause the manager application needs some
security elements to be configured prior to being accessed.

Environment Configuration

· Let us taken my tomcat7 setup as an example and I will paste the steps what I did to make it
working.

· I have installed my Tomcat7 in CENTOS server at /apps/tomcat/tomcat7 directory and this is


my CATALINA_HOME Now you need to find your CATALINA_HOME before continuing with the
next steps.

Update Roles and User credentials - Configuring Tomcat Security

· Got to $CATALINA_HOME/conf directory and look for tomcat-users.xml file.

· Open the file in your favourite editor like VI or nano and add the following lines right before
the last line
Software Development lab Manual

<user username="tomcatmanager" password="password" roles="manager-gui"/>

<user username="deployer" password="password" roles="manager-script"/>

· Here we are creating two usernames named tomcatmanager and deployer. here the deployer
account would be used to deploy the WAR file over http.

· manager-gui based tomcatmanager user would be used to manage the manager web
application at http://<HostName>:8080/manager

· Note*: If you are using Tomcat8+ version, Steps to enable manager application might be
different. Refer the product version specific documentation if you get stuck.

· Now we are ready with the Tomcat Servlet Container aka Application server and it is ready to
be connected from Jenkins.

Jenkins Configuration
· I presume that you have a Running Jenkins Server and a Administration Access

Step1: Make Sure you have Git and Maven installed

· In Jenkins UI, Goto Manage Jenkins -> Global Tool Configuration Section of Jenkins

· Note*: If you are not able to see a Manage Jenkins Option, You need to consult with your
Administrator. It might be due to insufficient privileges.

Step2: Install Deploy to Container Plugin.

· Manage Jenkins -> Manage Plugins -> Available -> Deploy to Container Plugin

Note:* For the Next step we have selected a Maven Job as our Choice. you can also create a Free
Style Project and use Gradle or Ant as your build tool .

Step3: Create and Configure a Maven Job with Source Code Management (Github)

· New Item -> Maven Project

· In the Configuration Section, Under Source Code Management Fill your


Github/BeanStalk/Gitlab Repository URL

· For testing you can use one of our Sample Application Named Tomcat Maven App from our
Github public Repository.

· You can use this GITHUB Repository


Software Development lab Manual

· Click on Add button displayed near the Credentials drop-down and enter the username and
password of your SCM Repo and Once it is saved. It would be available on the Dropdown for you to
select.

· Once you have selected the valid Credentials to wait for few seconds. If you see any error
message in RED colour which means your connection to the SCM repository is unsuccessful. Check
the URL or the credentials and retry.

Step4: Configure the Post-build Action and Specify the Tomcat Server Details

· Drag to the bottom and Go to the Post-build Actions section

· Click on Add post-build action button

· On the available options click on the Deploy war/ear to container

· Fill the required parameters for the plugin. Use the following Screen Shot as the reference

· Choose the Context Path in which the application should be installed. It would rename the
WAR file before deploying to the server and thereby the application context root would be changed.

· Tomcat URL http://[Tomcat Server Host]:[Primary http port]/

Build Jenkins Job

· Execute the Job you have created by clicking on the Build Now button

· Console Output after the Successful build.

· At the last line you can see that the WAR file has been generated and deployed on the remote
server.in our case, http://192.168.0.107:8081/

Testing the Application

· As the deployment is completed and the Jenkins Job ran Successfully without issues. ( Or So I
presume)

· Let us test our application.

· In my case, the URL should be as follows


Software Development lab Manual

· http://192.168.0.107:8081/TomcatMavenApp

· That's all. You have successfully configured Tomcat with Jenkins Continuous Deployment .

OUTPUT:
—-------------------------------------------------------------------------------------------------------------

Exercise 5:
Implement Jenkins Master-Slave Architecture and scale your Jenkins standalone
implementation by implementing slave nodes.

Jenkins Master and Slave Architecture


· The Jenkins master acts to schedule the jobs, assign slaves, and send builds to slaves to

execute the jobs.

· It will also monitor the slave state (offline or online) and get back the build result responses

from slaves and the display build results on the console output. The workload of building jobs is

delegated to multiple slaves.

Steps to Configure Jenkins Master and Slave Nodes


· Click on Manage Jenkins in the left corner on the Jenkins dashboard.

· Scroll down, Click on Manage Nodes and clouds.

Select New Node and enter the name of the node in the Node Name field.

Select Permanent Agent and click the OK button. Initially, you will get only one option,
“Permanent Agent.” Once you have one or more slaves you will get the “Copy Existing Node” option.
In the above screen shot, Parallel_Agent_01 was Created and currently it is in offline mode.

Click on configure, Provide the details.

1. Name -Parallel_Agent_01,

2. Number of executors- 5

3. Remote root directory– We have to provide Jenkins path

4. Labels-Parallel_Agent
Software Development lab Manual

5. Launch method-Launch agent by connecting it to the master

Node Properties Tab:


· Check Environment variables

o Provide the Java path

· Check Tool Locations:

o Provide the Git path and click on save button.

Click on Go to security configuration screen and change it. It will redirect to Configure Global
Security -> Agents ->click on Fixed radio button port: 49187 and click on save Button. Go back to
Nodes settings.

· We can see the above screen,

1. Click on Launch button, it will download the launch agent in your system.

2. Jenkins- slave.exe file should copy in the Jenkins folder which you installed in your system.

3. Double Click on jenkins – slave.exe.


4. Run the launch agent, click on run button and it will show connected.
5. In below screen shot, we can see the connected popup, click on file menu, select the install as
service and click yes button . Once it is done, refresh the page.

· In above screenshot, we can see the Build executors. One is master and other is

Parallel_agent_01

o In Master node, we can see number of executors as 2.

o In Parallel_agent_01, we can see number of executors as 5.

· Go to build job -> configure

· In General tab, check on Restrict where this project can be run.

· In Label Expression, we have to select node name where we need to execute the build job.

· We can create the more number nodes as well.

OUTPUT
—-------------------------------------------------------------------------------------------------------------
Software Development lab Manual

Docker
Docker is a platform that enables developers to package applications and their dependencies
into a standardized unit called a container. Containers are lightweight, portable, and ensure that the
application runs consistently across different environments.

Here are some key concepts and components of Docker:

1. Docker Engine: This is the core component that runs and manages containers. It includes a
server (the Docker daemon), a REST API for interacting with the Docker daemon, and a
command-line interface (CLI) called docker.

Check Docker Version:

docker --version

2. Containers: These are instances of Docker images. They encapsulate the application and its
dependencies in a portable and isolated environment. Containers share the host OS kernel
but run in separate user spaces.

Run a Container
docker run -it <options> <image-name>

-it: interactive terminal


-i: stands for interactive. It keeps the standard input (stdin) open,
allowingyou to interact with the container.
-t: stands for tty. It allocates a pseudo-TTY (terminal) for the
container, which provides a terminal interface.

3. Docker Images: These are read-only templates used to create containers. An image includes
everything needed to run an application, including the code, runtime, libraries, and
dependencies. Images are built from Dockerfiles.

List Docker Images


docker images
List Running Containers
docker ps
List All Containers (including stopped ones)
docker ps -a
Stop a Running Container
docker stop <container-id>
Remove a Container
docker rm <container-id>
Remove an Image
docker rmi <image-id>
Software Development lab Manual

4. Dockerfile: A text file that contains a series of instructions on how to build a Docker image. It
specifies the base image, sets up the environment, installs dependencies, and copies files.

 Build an Image from a Dockerfile


docker build -t <image-name>:<tag> <path-to-Dockerfile>
For example:
docker build -t my-app:latest .
 View Logs of a Container
docker logs <container-id>

5. Docker Hub: A cloud-based registry service where you can find, store, and share Docker
images. Docker Hub provides a public repository for community-contributed images as well
as private repositories for proprietary images.

Pull an Image from Docker Hub


docker pull <image-name>

6. Volumes: These are used for persisting data generated by and used by Docker containers.
Unlike container file systems, volumes exist independently of containers and can be shared
across containers.

 List Docker Volumes


docker volume ls

7. Networking: Docker provides networking capabilities to allow containers to communicate


with each other and with the outside world. Docker networks can be used to control how
containers connect and communicate.

 Clean Up Unused Docker Objects


docker system prune
 List Docker Networks
docker network ls

8. Docker Compose: A tool for defining and running multi-container Docker applications. With
Docker Compose, you can use a YAML file to configure the services, networks, and volumes
needed for your application and then start everything with a single command.

 Start Services Defined in docker-compose.yml


docker-compose up
 Run Services in the Background
docker-compose up -d
 Stop Services
docker-compose down
 View Logs of Services
Software Development lab Manual

docker-compose logs

Docker has become a popular choice for containerizing applications due to its efficiency, consistency,
and ease of use. It’s widely used in development, testing, and production environments.

OUTPUT:

---------------------------------------------------------------------------------------------------------------------------------

Ex.No 6 Docker using Debian Container

11.09.2024

Aim:

To install Debian in a Docker container, enabling you to create and manage a Debian environment
for development, testing, or other purposes.

Procedure:

Docker installation

Pull Debian Docker Image

Run a Debian Container

Update and Install Software Inside the Container

Write a python program

Implementation steps:

Steps for installation of Docker on windows

1. Download the Docker Desktop Installer.exe

2. Then, double-click on the Docker Desktop Installer.exe to run the installer.

3. Once you start the installation process, always enable Hyper-V Windows Feature on the
Configuration page.

4. Then, follow the installation process to allow the installer and wait till the process is done.

5. After completion of the installation process, click Close and restart.

Pull Debian Docker Image

Step1: Debian

Debian is a stable and versatile open-source operating system based on the Linux
kernel, known for its robust package management system and extensive software repositories. It is
developed by a global community of volunteers and is widely used for both servers and desktops.
Debian serves as the foundation for many other popular distributions, including Ubuntu. Its release
cycle focuses on thorough testing and reliability.
Software Development lab Manual

Step2: Pull the Debian image

docker pull Debian

Run a Debian Container:


Step1: List All Containers (including stopped ones)

docker ps -a

Step2:Run the Debian image

docker run -it Debian


Step3:Start the Debian Container

Docker start <Debian-Container-Id>

Step4:Execte the Debian Container

Docker exec -it <Debian-Container-Id> /bin/bash

You should now be inside a Debian container, indicated by a command prompt that may
look like root@<container-id>:/#.

Update and Install Software Inside the Container:

Step1:Update apt:

apt update

Step2:install nano file editor:

apt install nano

Step3:install python:

apt install python3

Write a python program:

Step1:open the file on nano editor:

nano fibo.py

GUI editor open on terminal write a program

Step2: Fibonacci series

def fibonacci_iterative(n):

"""Generate Fibonacci series up to the nth term using iteration."""

sequence = []

a, b = 0, 1

for _ in range(n):

sequence.append(a)

a, b = b, a + b
Software Development lab Manual

return sequence

# Example usage

n = 10

print(fibonacci_iterative(n))

Step3:run python program

Python3 <filename.py>

Ex:

Python3 fibo.py

Result:

Output:

--------------------------------------------------------------------------------------------------------------------------------

Ex.No 7 Customization using Debian Container

12.09.2024

Aim:

To rename Docker image by assigning it a new name, making it easier to manage and identify images
in your Docker environment.

Procedure:

List Docker Images: Identify the image you want to rename.

Tag the Image: Create a new name for the image.

Verify the New Tag: Ensure the new name appears correctly.

Implementation steps:

1. List Existing Docker Images

● Objective: Identify the Docker image you want to rename.


Software Development lab Manual

● Command:

docker images

● Explanation: This command lists all Docker images, including their repository names, tags,
image IDs, and sizes.

2. Tag the Docker Image with a New Name

● Objective: Create a new tag for the Docker image, effectively renaming it.

● Command Syntax:

docker run -d -it --name <new-image-name> <image-name>

● Example:

docker run -d -it --name mydebian debian

● Explanation: This command tags the existing image debian with a new name mydebian . The
simply adds a new reference to the same image.

3. Verify the New Tag

● Objective: Confirm that the new name has been successfully applied.

● Command:

docker ps -a

● Explanation: This command will list all Docker images, showing the new tag alongside the
old one. Ensure that the new tag mydebian appears in the list.

Output:

--------------------------------------------------------------------------------------------------------------------------------
Software Development lab Manual

Ex.No 8 Docker using Apache Server Container


16.09.2024

Aim:
To run an Apache HTTP Server (httpd) in a Docker container, allowing you to deploy and test a web
server environment quickly and efficiently.
Procedure:
Ensure Docker is Installed: Verify Docker is available.
Pull the httpd Image: Download the Apache HTTP Server image.
Run the Container: Start a container running the Apache HTTP Server.
Verify the Container: Check if the container is running and accessible.
Access the Server: Open a browser to see the Apache welcome page.
View Logs (Optional): Check logs for details or troubleshooting.
Stop and Remove (Optional): Clean up the container when done.
1. Ensure Docker is Installed

● Objective: Make sure Docker is installed and running on your system.

● Command:
docker --version

● Explanation: This command checks if Docker is installed by displaying its version. If


Docker is not installed, follow the Docker installation guide for your operating system.
2. Pull the httpd Image from Docker Hub

● Objective: Download the official Apache HTTP Server image from Docker Hub.

● Command:
bash
Copy code
docker pull httpd

● Explanation: This command fetches the latest httpd image from Docker Hub. The httpd
image contains the Apache HTTP Server.
3. Run the Apache HTTP Server Container
Software Development lab Manual

● Objective: Start a new container running the Apache HTTP Server.

● Command:
docker run -d -p 80:80 --name my-httpd httpd

● Explanation:
o -d: Runs the container in detached mode (in the background).
o -p 80:80: Maps port 80 on the host to port 80 on the container, allowing access to the
web server from the host machine.
o --name my-httpd: Assigns the name my-httpd to the container for easier reference.
o httpd: Specifies the Docker image to use.
4. Verify the Container is Running

● Objective: Check that the httpd container is running correctly.

● Command:
docker ps -a

● Explanation: This command lists all running containers. Ensure that my-httpd is listed with
the correct ports and status.
5. Access the Apache HTTP Server

● Objective: Verify that the Apache HTTP Server is accessible from your web browser.

● Steps:
Open a web browser.
Navigate to http://localhost or http://<your-ip-address> (replace <your-ip-address>
with the IP address of the host running Docker).

● Explanation: You should see the default Apache HTTP Server welcome page, indicating that
the server is running correctly.
● Edit page: File location:/usr/local/apache2/htdocs/index.html to Edit html file
6. View Logs (Optional)

● Objective: Check the logs to see the output or errors from the Apache HTTP Server.

● Command:
docker logs my-httpd

● Explanation: This command displays the logs from the my-httpd container, which can help
in troubleshooting issues or verifying server output.
Software Development lab Manual

7. Stop and Remove the Container (Optional)

● Objective: Stop and clean up the container when you no longer need it.

● Commands:
Stop the container:
docker stop my-httpd
Remove the container:
docker rm my-httpd

● Explanation: Stopping and removing the container frees up system resources. You can restart
or remove containers as needed.
Output:

---------------------------------------------------------------------------------------------------------------------
Ex.No 09 Ip Configuration in Apache httpd container
26.9.2024

Aim:

Procedure:

1.Verify docker is available

2.Download the Apache HTTP server image

3.Start a container which running on the Apache HTTP server

4.check the container is running or not

5.set any Ip address for the localhost sever in apache http container
Software Development lab Manual

6.open web browser and type the ip address you set and run it

Implementation steps :

1. Install docker or make sure docker is running on your system

Command: docker --version

Note: this command is used check if the docker is installed by displaying its
version.

2.Download Apache HTTP server image from Docker hub.

Command: docker pull httpd

Note: this command is used to download the official Apache HTTP Server
image from Docker Hub to your local machine.

3. This command runs an Apache HTTP server in a Docker container, maps


port 80 inside the container to port (4567) on your host machine, and names the
container my_httpd. You can then access the server by navigating to
http://localhost:4567.

Syntax: docker run -d -it --name <container_name> -p 4567:80 httpd

Command: docker run -d -it --name my_httpd -p 4567:80 httpd

Note:

docker run: This command runs a new container.

-d: Detached mode, which means the container will run in the background.

-it: Combines two options:

● -i: Keeps the STDIN open to allow interaction.


● -t: Allocates a pseudo-TTY (interactive terminal).

--name <container_name>: This assigns a name to the container. Replace


<container_name> with the desired name for your container, e.g., my_httpd.

-p 4567:80: Port mapping:


Software Development lab Manual

● 4567: The port on your local machine (host).


● 80: The port inside the container where the Apache HTTP server (httpd)
is running.

httpd: This is the image name. Apache HTTP Server will be run inside the
container.

4.docker start command is used to start the previously stoped container

Syntax: docker start <container_name>

Command: docker start harini

Note:

docker start: This command starts a stopped container.

harini: The name (or ID) of the container you want to start.

5. The command is used to start an interactive Bash shell inside a running


Docker container.

Syntax : docker exec –it <container_name> /bin/bash

Command:docker exec –it harini /bin/bash

6. The cd command is used to change directories in a Unix-like system (Linux,


macOS, etc.) or in the command line of Windows (if using a Unix-like shell
such as Git Bash or WSL).

Command: cd htdocs

Note:

htdocs: The target directory where you want to navigate. In the context of a web
server, the htdocs directory often contains the web files served by the server
(commonly used in Apache HTTP Server)

7. After complete all the commands ,it shows the file name

In this we have used nano compiler so use this required command

Command: nano index.html

Note: index.html – it is a file name


Software Development lab Manual

8.open the web browser and type localhost:4567

Click enter its shows the output on the screen

…………………………………………………………………………

---------------------------------------------------------------------------------------------------------------------
Ex.No 10 Host a registration form webpage using Apache httpd container
02.10.2024

---------------------------------------------------------------------------------------------------------------------

Ex.No 11 Jenkins Integration with Selenium


09.10.2024

Installation of Selenium and Jenkins


Before heading over to the Jenkins integration with Selenium, let’s take a look
at how to install and set up both Jenkins and Selenium.

Steps to Download Jenkins


1. Download Jenkins from their official website.

2. Unzip the file and open the Jenkins exe file.

3. Click ‘Next’ to start the installation.


Software Development lab Manual
Software Development lab Manual

4. Click the Finish button to complete the installation process.


Software Development lab Manual

5. You will be redirected automatically to a local Jenkins page, and the port
number would be 8080 by default. We can also launch a browser and navigate
to the mentioned URL http://localhost:8080

Creating an admin account to access Jenkins


1. You can obtain and enter the secret password by navigating to the mentioned
path as shown in the below image. Once you have entered the password, click
on Continue.

2. After entering the secret password, you will be asked to install plugins. Click
on the required plugins option so that the recommended plugins could be
downloaded and installed.
Software Development lab Manual

3. After the successful installation, you will be asked to create an administrator


account with the following details that are mentioned in the screenshot.

4. Once you have successfully installed Jenkins, the default Jenkins dashboard
can be seen as shown below.
Software Development lab Manual

Jenkins integration with Selenium


The Jenkins integration with Selenium can be achieved in various ways and we
will be focusing on how it can be established using Maven in this guide. Let us
quickly introduce what is Maven, why we have chosen Maven, and go through
the installation process as well.

What Is Maven?
Maven is a software project management & build management tool which
allows us to add and manage all the dependencies in a single pom.xml file.

Why Maven for Jenkins integration with Selenium?


1. It can act as the central repository to get dependencies

2. Maven helps to maintain a common structure across the organization

3. It makes integration with CI tools easier.

How to Install Maven?


Software Development lab Manual

1. Download Maven from their official site.

2. Then add MAVEN_HOME under system variables as shown below

3. Now, set up the path for the bin directory of the maven directory.
Software Development lab Manual

4. To verify if maven has been installed successfully, type the following


command in the command prompt.

1 mvn --v

5. Post the verification, you can go ahead and create a maven project and add
the maven dependencies in the pom.xml file that will be used to achieve Jenkins
Integration with Selenium.
Software Development lab Manual

POM.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>MyfirstDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>E:\MyfirstDemo\testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>

Using the Java class ‘Sample.java’, we create a WebDriver script. Jenkins


Integration with Selenium
Software Development lab Manual

package Demo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class Sample {
@Test
public void demo() {
System.setProperty("webdriver.chrome.driver","src/Drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.cricbuzz.com/");
String baseTitle = driver.getTitle();
System.out.println("title =" + baseTitle);
driver.manage().window().maximize();
}
}

TestNG.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestSuite">
<test name="demo">
<classes>
<class name="Demo.Sample">
</class>
</classes>
</test>
</suite>

How To Integrate Selenium Tests In


Maven With Jenkins?
So the next aspect that we are going to cover in this Jenkins Integration with
Selenium guide is to see how to integrate Jenkins with Selenium WebDriver and
how Maven is instrumental in the integration of Jenkins with Selenium test
scripts. For a crystal clear understanding, we have also added screenshots of all
the important steps.

Start the Jenkins server and launch the browser and navigate to the localhost
using the mentioned URL http://localhost:8080.

Steps:
Software Development lab Manual

1. The first and foremost step would be to create a new project by choosing the
‘New Item’ option from the Jenkins dashboard.

2. Obviously, the next step would be to give the new project that we have
created a name. In this case, we have used “DemoProject” as the name of the
project for explanation purposes. It goes without saying that you can name the
project as per your wish. Once the name has been entered, we have to select
‘Maven project’ as the option from the given list and then click on OK.
Software Development lab Manual

3. The created project file can be seen in the Jenkins dashboard, and so we
would have to select the project from the list to proceed further.

4. From the many options that appear on the left, click on ‘Configure’.

5. Automatically Jenkins takes us to the project configuration view where we


can configure the project-related details
Software Development lab Manual

under the General tab. As shown in the image, this section includes the name
and description of the project.

6. The next section is the Source Code Management, under which we have to
select the ‘None’ option.

The Git Option:


Here, we select ‘None’ in the Source Code Management section as we just need
a build.
If you select Git, you would need to commit to the repository and enter the
credentials by clicking on ‘Add’. In this Jenkins Integration with Selenium
guide, we will be only focusing on the aspects and features needed to make the
integration possible.

7. So we can head straight to the Build section next, and it would require two
important steps to load the POM.xml file. Under the Root POM, you have to
enter the complete path of the pom.xml that you have created. Under the Goals
and options, you would have to enter the following command
Software Development lab Manual

1 clean test

8. Once these crucial pieces of information have been filled in, we can scroll
down and click on ‘Apply’ and then finally ‘Save’.

9. Once the above step is completed, we head back to the project where we have
to click the ‘Build Now’ option.
Software Development lab Manual

10. Now that we have manually triggered the build in Jenkins, the job will run
after the completion of the build.
Software Development lab Manual

11. The results can be viewed in the console output as shown below.

You might also like