Git & Github | Jenkins| Docker

Git & Github | Jenkins| Docker

  • Git bash commands for pushing the code in github repo
  1. Open Git Bash
  2. Change the current working directory to your local project.
  3. 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.

No alt text provided for this image





No alt text provided for this image


No alt text provided for this image
No alt text provided for this image


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

No alt text provided for this image

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.

No alt text provided for this image

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

No alt text provided for this image


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

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image


FOR ANY QUERY OR ENHANCEMENT KINDLY CONTACT ME

Email : citygirl3009@gmail.com

Github repo: https://github.com/Neha680/Task1_n

To view or add a comment, sign in

More articles by Neha Gupta

Others also viewed

Explore content categories