DEVOPS AUTOMATION
Introduction of applications used:
- Github : Github is a centralised system where we can upload or download the code .It is good example of SCM where we can store ,manage and roll-bcak our code.
- Docker : Docker is a container tool where we can setup OS just a second ,by downloading and configuring .It also works as a fast technique for deploying the code.
- Jenkins : Jenkins is used to build and test your software projects continuously. It will integrate the code easier.
Creating a repository in Github:
Create a repository and initialize it .
In Git Bash:
##creating local repo##
1.Cloning the github repo in GIT BASH.
2.POST-COMMIT : creating a notepad file for post commit
Why use post-commit? In Jenkins post-commit are used to trigger the build whenever a developer commits something to the master branch.
Code:
#!/bin/bash
git push
3.Creating a branch (dev1)
Jenkins:
- Creating Job1
and configuring the repo we made in git hub
Writing shell code to be run in RHEL 8:
if sudo docker ps | grep main_server
then
echo " Server is already running"
else
sudo docker run -d -t -i -p 8081:80 -v /main_directory:/usr/local/apache2/htdocs --name docker_server httpd
fi
sudo cp -r -v -f * /main_driectory/
Creating Job 2:
Writing shell code to be run in RHEL 8:
if sudo docker ps | grep test_server
then
echo " Server is already running"
else
sudo docker run -d -t -i -p 8081:80 -v /test_directory:/usr/local/apache2/htdocs --name docker2_server httpd
fi
sudo cp -r -v -f * /test_directory/
Creating Job 3:
Master branch is configured with Job1 which automatically deploy the data.
Dev1 Branch is configured with Job2 which automatically deploy docker container.
Job3 is made for testing . If testing is successful then jenkins will merge the dev1 branch to master branch .And alos it will trigger the job1.
Good performance project..