Integrating Jenkins,Docker and Git Hub and creating an Automated Web Development environment

Integrating Jenkins,Docker and Git Hub and creating an Automated Web Development environment


Task:

JOB#1

If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.

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.

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


pre-requsites:

  • Jenkins should be installed in Red-Hat OS and the service should be started there
  • Download ngrok,and unzip it
  • Create two folders for testing and deployment i,e testing directory and deploy directory
  • Docker should be installed in Red-Hat OS and the services of docker should be active and running
  • Git bash should be installed in your windows environment and should have an account in git hub


Process :

1: Create a new repository in git hub,make it public but do not initialize it,it would look something like this:

No alt text provided for this image

2:Now,open your git bash and in your Task1 folder create a file called index.html (or any other kind of file you want for this task),initialize the git by git init command create a remote repository,then add and commit your file,and then push it to your git hub repository.

3:Create a dev branch by using git checkout command:- git checkout -b dev

4:Go to .git/hooks directory and create a file called post-commit,here add a bash command git push,what it does is pushes the files we created after we commit

The above steps are the initial steps to be done before creating the jobs of our task,and this looks something like this:

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

5:Before proceeding further root access to jenkins so that it can deploy docker and to do other tasks like copy by giving access in sudoers folder: gedit /etc/sudoers there do this:

No alt text provided for this image

Apart from this u need to give permission for jenkins to copy in our red hat os in the testing and deploy directory we have created by using the command: setfacl -m u:Jenkins:rwx /directory_name

6:Create a job called Task1_job1,In this job in configuration add your github repo name and under build give the name of your branch folder,then add git scm polling as trigger,copy files into testing dir,launch a docker image for the webserver for branch if it is not present already and then save the job we have created

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

7:Create another job Task1_job2,here build master,create an additional behaviour to merge dev and master if dev build shows no error,build two trigger gitscm polling,this only monitors if merging was successfull or not.

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

8:Create another job which launches the final docker environment for master if all the jobs are successful and also add condition that the job will only run if all the previous jobs are stable.

No alt text provided for this image

9:Now,only a list thing os there to do,activate ngrok,it will create an ip use that ip as a webhook for github

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


The above steps I have mentioned can be used to Create an Automated Web Development environment, integrating Jenkins, Git/Github, Docker and httpd Web Server.


要查看或添加评论,请登录

社区洞察

其他会员也浏览了