You are on page 1of 24

Name : Vishal Gaikwad

Class : TE-IT
Roll No : A-4
ID : TU4F1819012
DevOps
Assignment No : 2

Q1 ) Install Jenkins on a platform on your choice.

Ans :

Jenkins is one of the most popular tools for continuous integration and continuous delivery on
any platform. As a Java application, Jenkins has many plugins for automating almost everything
at the infrastructure level. The use of Jenkins has widely increased rapidly due to a rich set of
functionalities, which it provides in the form of plugins.

1. First, you need to install OpenJDK. Jenkins currently only supports JDK8. Once Java is
running, you can install Jenkins.
Click here https://www.jenkins.io/download/ to download the latest Jenkins package for
Windows (currently it is version 2.).
 
2. Once it is downloaded, it will open a wizard. Click “Next” to start the installation.
3. Click the “Change…” button if you want to install Jenkins in another folder. In this example, I
will keep the default option and click on the “Next” button.

Enter the service logon credentials. It is recommended to select the second option “Run service
as local or domain user” as it is safer. To run Jenkins service using this option, you have to
enter the domain username and password. Click on the “Test Credentials” button to test your
domain credentials and it will enable the “Next” button. Click on the “Next” button.
 5. Enter the port on which Jenkins will be running. Click on the “Test Port” button to validate if it
is free. 
 

 
6.Select the Java home directory and click on the “Next” button.
 
 7. Select other services that need to be installed with Jenkins and click on the “Next” button.
 

 
8. Click the “Install” button to start the installation process.

 
9. The installation will proceed.

10. When done, click on “Finish” to complete the installation process.

 
11. You will automatically be redirected to a local Jenkins page, or you can paste the URL
http://localhost:8080 in a browser.

12. To unlock Jenkins, copy the password from the file intialAdminPassword. This file should be
found under the Jenkins installation path (set at step 3 in Jenkins installation). If a custom path
was entered, then you should check that location.
Copy the content of the initialAdminPassword file and paste it in the Administrator password
field. Then, click the Continue button.
13. You can install either the suggested plugins or selected plugins you choose. To keep it
simple, we will install the suggested plugins.

 
14. Wait until the plugins are completely installed.
15. The next thing that you should do is create an Admin user for Jenkins. Then, enter your
details and click Save and Continue.

 
16. Click on Save and Finish to complete the Jenkins installation.
 
17. Now, click on Start using Jenkins to start Jenkins.

 
18. Finally, here is the default Jenkins page.
 
Q2) Dockerize java project given.
Ans :
Docker builds images by reading instructions from a Dockerfile. A Dockerfile is a simple text file
that contains instructions that can be executed on the command line. It is a fundamental
building block used when dockerizing your Java applications, and it is how you can create a
Docker image that can be used to create the containers you need for automatic builds.

Ensure that docker is installed by running and checking with the following command in the
terminal:
$ docker –version
Clone a sample Java application or in your Java Application, add an empty file in the directory
called Dockerfile.
A Dockerfile always starts with another image called a “base-image”. This is the building block
for our image, and examples include things like a red hat image or an Ubuntu image.
If we start with an image that already has Java installed, we won’t have to install Java later in
the Dockerfile. If we don’t start with an image that is already installed, then we’ll have to install
Java. At the end, this Dockerfile will be used to build another image. This final image (with all
dependencies and the application added) can be delivered to those who want to run the
application.
Building the Dockerfile
We have to choose an image to start with. To make our base image Ubuntu, add this line:
FROM ubuntu : latest
“latest” will pull the latest published ubuntu image in DockerHub which is a public registry of
images available for use.
Install a dependency, the jre (which is required on any machine to run a java application).
Dockerfiles have a RUN command that we can utilize as if we were installing a jre on an ubuntu
machine from the command line.

RUN \
# Update
apt-get update -y && \
# Install Java
apt-get install default-jre -y

Now, image has java installed.


If java application is locally, build it with mvn clean install. This should build the java application
and put the jar in ./target/gs-serving-web-content-0.1.0.jar directory (example).
After we know the relative path of our jar to our Dockerfile, we can utilize the Docker ADD
command.

ADD ./target/gs-serving-web-content-0.1.0.jar spring-mvc-example.jar

This command
adds the local ./target/gs-serving-web-content-0.1.0.jar artifact as spring-mvc-example.jar .
When our application is running, it is running on port 8080. Use the docker EXPOSE command
to open up that port.

EXPOSE 8080

Utilize the
CMD docker command to run the jar.

CMD java -jar spring-mvc-example.jar

Altogether, the
Dockerfile should look like this:

# Pull base image.


FROM ubuntu:latest

RUN \
# Update
Build and Run the Image Locally
To build the image with the name spring-mvc-sample-image :
docker build . -t spring-mvc-sample-image
We can verify the image built correctly with docker images

$ docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
spring-mvc-sample-image latest 8fa27ad00edd 34 minutes ago
540MB

Bring up a
container called ‘sample-mvc-sample-container’ based on the image ‘spring-mvc-sample-
image’.
docker run -t -p 8080:8080 --name sample-mvc-sample-container spring-mvc-sample-image
Use ctrl + c to exit the container. Now command docker ps -a

$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
736f9cdc1499 spring-mvc-sample-image "/bin/sh -c 'java -j…" 2 hours ago
Up 2 hours 8080/tcp sample-mvc-sample-container

Finally, tag
and push the Image to the public Dockerhub
First, list the image and find the one you built

$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
spring-mvc-sample-image latest 8fa27ad00edd 34 minutes ago 540MB
Tag the image by grabbing the image id(8fa27ad00edd) and tagging it with the docker
username a name of your choice.
A docker tag consists of a name and a version , separated by a :
docker tag 8fa27ad00edd username/spring-mvc-sample-image:0.1

Push
docker push username/spring-mvc-sample-image:0.1

Find your image in DockerHub


You should be able to find it at cloud.docker.com after you log in, but the URL pattern appears
to be:
https://cloud.docker.com/repository/docker/<username>/<image_name>

Following are some use cases:


⮚ Simplifying Configuration
⮚ Code Pipeline Management
⮚ Developer Productivity
⮚ Allows consolidating multiple servers to save on cost
⮚ Includes the ability to checkpoint containers and container versions, as well as to diff two
containers

Q3) Build two pipelines with unit test automation.


Ans :
Step 1: Create a new Jenkins job :
Open a web browser and navigate to localhost:8080. Click Create New Jobs. You can also click
New Item on the left.
Step 2: Create a pipeline job
In this step, you can select and define what type of Jenkins job you want to create. Select
Pipeline and give it a name (e.g., TestPipeline). Click OK to create a pipeline job.

You will see a Jenkins job configuration page. Scroll down to find Pipeline section. There are
two ways to execute a Jenkins pipeline. One way is by directly writing a pipeline script on
Jenkins, and the other way is by retrieving the Jenkins file from SCM (source control
management).

Step 3: Configure and execute a pipeline job through a direct script


To execute the pipeline with a direct script, begin by copying the contents of the sample
Jenkinsfile from GitHub. Choose Pipeline script as the Destination and paste the Jenkinsfile
contents in Script. There are three Stages: Build, Test, and Deploy, which are arbitrary and can
be anything. Inside each Stage, there are Steps; in this example, they just print some random
messages.
Click Save to keep the changes, and it should automatically take you back to the Job Overview.

To start the process to build the pipeline, click Build Now. If everything works, you will see
your first pipeline (like the one below).

To see the output from the pipeline script build, click any of the Stages and click Log. You
will see a message like this.
Step 4: Configure and execute a pipeline job with SCM
Now, switch gears: In this step, you will Deploy the same Jenkins job by copying the Jenkinsfile
from a source-controlled GitHub. In the same GitHub repository, pick up the repository URL by
clicking Clone or download and copying its URL.

Click Configure to modify the existing job. Scroll to the Advanced Project Options setting, but
this time, select the Pipeline script from SCM option in the Destination dropdown. Paste the
GitHub repo's URL in the Repository URL, and type Jenkinsfile in the Script Path. Save by
clicking the Save button.

To build the pipeline, once you are back to the Task Overview page, click Build Now to execute
the job again. The result will be the same as before, except you have one additional stage
called Declaration: Checkout SCM.

Congratulations! You've built your first Jenkins pipeline!


Q4) Build and host database.
Ans :
Docker is a tool for simplifying deployment of applications, but containers can also make the
local development process easier and faster.
Instead of maintaining database installations in the local environment or connecting to test
databases in the cloud, use a Docker container. With Docker containers one can have multiple
versions of the same database easily accessible and quickly restore from backups to make sure
the test data is congruent with production data.

Advantages:
⮚ There’s less clutter on the development machine
⮚ One can work on multiple projects side by side, which depend on slightly different
database versions
⮚ One can create a development environment on any OS in a reliable fashion
⮚ Everything is “documented” through automation and reproducible
Docker is great for running databases in a development environment. One can even use it for
databases of small, non-critical projects which run on a single server. Regular backups should
be performed.

Following Prerequisites are required:


⮚ Docker
⮚ Node and npm
⮚ mysql shell client (to connect to the container using a local shell client)
⮚ loopback-cli (to follow the example for connecting from LoopBack)

Step 1 : Install Prerequisites

To check if Docker has installed correctly, open terminal and enter docker ps. If no running
containers, following output would be shown:

To check if Node is installed, enter node -v. Should get npm automatically with Node
installation, but to check, try npm -v.

Step 2 : Start a Docker container


Create a new Docker container using the mysql-latest official image hosted on Docker Hub.
docker run --name test-mysql -p 3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d
mysql:latest

If all went well, a long number is seen, which is the container’s ID.
Enter docker ps, information about the image is seen that was used to create the container
(mysql:latest in this example), when the container was created and how long it’s been running,
ports available (should be 3306/tcp) and the name given to it(test-mysql).

Step 3 : Add your own data


There are a few different ways to add data to a Docker container running MySQL.
Connect to your container using a local MySQL shell client
When above container was created, we exposed a port to the local environment (-p 3306).
Docker mapped that port can find that port by running docker ps.

Note the port number and enter the command below, where $PORTNUMBER is the port
assigned by Docker (32783 in this case):
mysql -P $PORTNUMBER --protocol=tcp -u root -p

Enter the password used when creating the container (whatever entered in place of my-secret-
pw).

Now connected to MySQL running in the container. This is helpful if we have a local datafile
NOT in SQL format that you want to load into a table. 

Add data from a file on your machine :


docker run --name test-mysql-2 -p 3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d
mysql:latest

Add data to a running container.


docker exec -i test-mysql-2 mysql -pmy-secret-pw mysql < /path/to/my/sqlfile/myfile.sql

Add your data when you create a container


Create a new container and have it load a .sql file
In the terminal, run the following, replacing my/own/datadir with the path to the SQL file:
docker run --name test-mysql-3 -v /my/own/datadir:/docker-entrypoint-initdb.d -p 3306 -e
MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=mysql -d mysql:latest

Run docker ps again to find the port to use to connect, and use the local MySQL client to check
on the new database.

Use Docker Compose to create your container and add data


Instead of running long commands in the terminal, use a docker-compose.yml file:
version: '3'
services:
mysql:
image: mysql:latest
ports:
- 8083:3306
volumes:
- ./test-sql-2:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: pwd
MYSQL_DATABASE: mysql

Then run docker-compose up -d in the same directory as the docker-compose.yml file. In this
example, we’ve assigned the port (8083). Docker will auto-magically generate a name for the
container.

Step 4 : Connect to your container using another container


Instead of installing MySQL shell client on the machine, one can create a container to run the
MySQL shell client and connect it to the MySQL container.

In the terminal, enter:


docker run -it --link test-mysql:mysql --rm mysql sh -c 'exec mysql
-h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot
-p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
In the above string, test-mysql is the name of the MySQL container. When one creates the test-
mysql container, a root password is created as an environment variable, and the above
command references it as $MYSQL_ENV_MYSQL_ROOT_PASSWORD.

The MySQL prompt can be seen as below :

Step 5 : Connect to your container from your application


LoopBack is an open source framework for creating APIs quickly and easily with Node.js. It can
be used with just about any database, including MySQL.
Creating a full set of CRUD APIs for a new Geonames database (example).

Wait for npm to finish installing, then cd into the directory name.
Now create a connection to MySQL with lb datasource:
And enter the connection information.

The connection string is mysql://root:pwd@localhost:8083/mysql in this case because we are


using the container created by docker-compose up -d, which explicitly set port 8083 and the
password pwd.

Next, we’ll create our model with lb model.

Add properties.
Check to make sure the MySQL container is up and running with docker ps

To run the API, just run the Node app that LoopBack created with node .

Open the Explorer URL in the browser.

Explore the data.


Q5) Identify and Prepare Deliverables.
Ans :
1. The concept behind a Deliverable is one of the essential concepts in the profession of
project management.
2. It takes several teams to develop large software projects. Very large projects require
multiple autonomous teams that can manage their own backlog and priority while
contributing to a unified direction for that project.
3. Regular reviews of the project schedule with these teams help ensure that the teams are
working toward common goals.
4. Project deliverables must be identified at the start - when the project is first proposed. As
the project moves forward, and deliverables are further defined and specified, the need
for one or more related process deliverables will come in to focus.
5. As a whole, this deliverables definition process is executed via the deliverables decision
tree. The deliverables decision tree (detailed below) is made up of a series of questions
used to identify and define required deliverables – both from a project and process point
of view.
6. Test Deliverables are the test artifacts which are given to the stakeholders of a software
project during the SDLC (Software Development Life Cycle).
7. A software project which follows SDLC undergoes the different phases before delivering
to the customer. In this process, there will be some deliverables in every phase.
8. Some of the deliverables are provided before the testing phase commences and some
are provided during the testing phase and rest after the testing phase is completed.
9. Every software application goes through different phases of SDLC and STLC. In the
process of software application development, test teams prepare different documents to
improve communication among the team members and other stakeholders.
10. These documents are also known as Test Deliverables, as they are delivered to the
client along with the final product of software application.

You might also like