Git & Github | Jenkins| Docker
- Git bash commands for pushing the code in github repo
- Open Git Bash
- Change the current working directory to your local project.
- Initialize the local directory as a Git repository.
git init
4. Add the files in your new local repository. This stages them for the first commit.
git add .
5. the files that you’ve staged in your local repository.
git commit -m "initial commit"
6. Copy the https url of your newly created repo
7. In the Command prompt, add the URL for the remote repository where your local repository will be pushed.
git remote add origin remote repository URL
git remote -v
8. Push the changes in your local repository to GitHub.
git push -f origin master
JOB#1 If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.
BUILD CODE
if sudo docker ps | grep devdocker
then
echo "SERVER ALREADY RUNNING"
else
sudo docker run -dit -p 4100:80 -v /var/www/html/:/usr/local/apache2/htdocs/ --name devdocker httpd
fi
sudo cp -r -v -f * /var/www/html
JOB#2 If Developer push to master branch then Jenkins will fetch from master and deploy on master-docke environment. both dev-docker and master-docker environment are on different docker containers.
BUILD CODE:
sudo mv dev.html index.html
sudo cp -r -v -f * /Task1
if sudo docker ps | grep masterdocker
then
echo "SERVER ALREADY RUNNING"
docker rm -f masterdocker
sudo docker run -dit -p 4300:80 -v /Task1/master/:/usr/local/apache2/htdocs/ --name masterdocker httpd
else
sudo docker run -dit -p 4300:80 -v /Task1/master/:/usr/local/apache2/htdocs/ --name masterdocker httpd
fi
JOB#3 Manually the QA team will check (test) for the website running in dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger #job 2
FOR ANY QUERY OR ENHANCEMENT KINDLY CONTACT ME
Email : citygirl3009@gmail.com
Github repo: https://github.com/Neha680/Task1_n
Good Work 👍