SDT Lab Manual
SDT Lab Manual
Exercise 1 : Write a procedure to Deploy Version Control System / Source Code Management, install git and
create a GitHub account.
Aim:
Procedure:
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:
$ git --version
Step 3:
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).
Step 4:
$ mkdir test
$ cd test
Step 5:
$ 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:
Step 9:
Step 10:
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:
Step 13:
Push the local file onto the remote repository using the following command:
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.
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.
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
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.
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.
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
● 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 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
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.
The Jenkins is being restarted, It is about to restart. Again, log in to Jenkins UI.
In the General section, enter the project description in the Description box.
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.
· 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
· 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
· 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.
· 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)
· For testing you can use one of our Sample Application Named Tomcat Maven App from our
Github public Repository.
· 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
· 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.
· Execute the Job you have created by clicking on the Build Now button
· 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/
· As the deployment is completed and the Jenkins Job ran Successfully without issues. ( Or So I
presume)
· 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.
· 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
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.
1. Name -Parallel_Agent_01,
2. Number of executors- 5
4. Labels-Parallel_Agent
Software Development lab Manual
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.
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.
· In above screenshot, we can see the Build executors. One is master and other is
Parallel_agent_01
· In Label Expression, we have to select node name where we need to execute the build job.
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.
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.
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>
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.
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.
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.
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.
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.
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:
---------------------------------------------------------------------------------------------------------------------------------
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
Implementation steps:
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.
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
docker ps -a
You should now be inside a Debian container, indicated by a command prompt that may
look like root@<container-id>:/#.
Step1:Update apt:
apt update
Step3:install python:
nano fibo.py
def fibonacci_iterative(n):
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))
Python3 <filename.py>
Ex:
Python3 fibo.py
Result:
Output:
--------------------------------------------------------------------------------------------------------------------------------
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:
Verify the New Tag: Ensure the new name appears correctly.
Implementation steps:
● Command:
docker images
● Explanation: This command lists all Docker images, including their repository names, tags,
image IDs, and sizes.
● Objective: Create a new tag for the Docker image, effectively renaming it.
● Command Syntax:
● Example:
● Explanation: This command tags the existing image debian with a new name mydebian . The
simply adds a new reference to the same image.
● 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
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
● Command:
docker --version
● 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
● 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
● 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
● 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:
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 :
Note: this command is used check if the docker is installed by displaying its
version.
Note: this command is used to download the official Apache HTTP Server
image from Docker Hub to your local machine.
Note:
-d: Detached mode, which means the container will run in the background.
httpd: This is the image name. Apache HTTP Server will be run inside the
container.
Note:
harini: The name (or ID) of the container you want to start.
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
…………………………………………………………………………
---------------------------------------------------------------------------------------------------------------------
Ex.No 10 Host a registration form webpage using Apache httpd container
02.10.2024
---------------------------------------------------------------------------------------------------------------------
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
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
4. Once you have successfully installed Jenkins, the default Jenkins dashboard
can be seen as shown below.
Software Development lab Manual
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.
3. Now, set up the path for the bin directory of the maven directory.
Software Development lab Manual
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>
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>
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’.
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.
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.