Web Development Environment (Automated)
Objectives :
1 > To create a job in Jenkins to fetch the data from master branch of github repository on every update and deploy into docker container which has a support of httpd(apache) server.
2 > To create new branch as a developer branch in github which fetch the data on every updates and deploy into testing environment for testing .
2 > After the success of testing , the dev branch will merged into master branch and trigger to job1 for production deployment.
*Software needed : GIT , Jenkins and Docker .
*Base OS : Windows 10 --> git installed
*Virual BOX : Redhat 8 --> jenkins and docker installed .
Lets Start :
Tasks on GIT : to upload local repository to github and to create a new branch .
- To create a new repository on GitHub
- Open Git Bash. Change the current working directory to your local project.
- Initialize the local directory as a Git repository = "git init"
- Add the files in your new local repository. This stages them for the first commit = "git add ."
- Commit the files that you’ve staged in your local repository = git commit -m "initial commit"
- Copy the https url of your newly created repo
- 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
- Push the changes in your local repository to GitHub = "git push origin master "
Now the local repository has been added to the github .
- To create a new branch = "git checkout -b dev"
- To switch into dev branch from master = "git checkout dev"
- Now this branch also has to be pushed to github repository = "git push origin dev"
Now the github repository will also have the new branch dev .
NOTE :- origin is just a name of the repository .
Tasks on Jenkins :
Created a job with a name master_job, which fetch the data from github repository URL.
Build Trigger- Poll SCM which periodically check for the updates and it also trigger after merge_job
Execute shell- commands to run the docker container in httpd server.
Created second job with name dev_job which fetch the files from dev branch.
Build Trigger - Poll SCM which periodically checks for the updates
Execute Shell - commands to run the files on container in httpd server for testing.
Created third job with a name testing_job which job is to test the deployed pages are running successfully or not.
It will build after the dev_job.
Execute shell - commands for testing the deployed files.
Created fourth job with a name merge_job which job is to merge both the branches i.e. from dev to master . In this job we also have to provide credentials of github to jenkins to acces persmissions to merge the branches.
We are merging dev branch into master so we have to specify the branch dev.
Now we have to specify in which branch we are merging i.e. master and the name of the repository which i have given origin.
This job will run after the testing_job .
After the merge it will auto push the files to the github repository.
Now all the jobs are properly configured and ready to build .
I used build pipeline for better look and feel .
CONCLUSION - From dev branch, if any commits appear it will trigger the job dev_job and the chain of job begins , the dev_job will deploy the files into docker container for testing then testing_job will give status of the testing and trigger the merge_job and it get merged into master_branch and then it trigger to master_job which will deploy the files inton production environment by docker container.
Electrical Engineer
4 年Is this pol scm in Jenkins for scheduling git update or something else, didn't get it?