Aim : As soon as a developer makes some changes (or commits in Git for the website) it is automatically send to the QA-team , after their approval then only changes will be reflected to the main website.
Three jobs to be done:
Job1: If developer push the code from master branch then Jenkins will fetch from master and deploy to production_team webserver (created using docker).
Job2: If developer push the code from dev_branch(other than main) then jenkins will fetch from dev_branch and deploy on testing_team webserver (created using docker).
Job3: QA-team will test the new code , if it is running fine then Jenkins will merge dev_branch with the master branch. and triggers job1.
Setting up server system:
Creating two directories :
-Stop firewall and selinux:
systemctl stop firewalld
setenforce 0
Start docker and Jenkins services:
systemctl start docker systemctl start jenkins
Setting up Github
Create a new repository.
Now go to developer side :
notepad .git/hooks/post-commit (Create hooks) #!/bin/bash git push ( To automatically push as soon as you commit.)
cat > index.html ( new page created add data and press ctrl + D to save) git add . ( to stage) git commit . -m " first commit" ( will be uploaded to git automatically)
git push --set-upstream origin solaris (Sync if not)
Create newbranch(dev_branch).As soon as you edit the code in dev_branch and add commit its is automatically uploaded to github(dev_branch).
Jenkins set up:
- Install github plugin. Click on new Item and create job as follows:
Production_job configure:
Click on configure:
You can also use triggers to automate more faster as compare to Poll SCM.
CODE:
Testing_job configure:
CODE:
QA-team configure:
CONCLUSION:
As soon as developer made changes and commits.
(“New changes made by developer”)
Jenkins automatically does his job.
First do testing_job >>QA-team-checking>>Production_job
And at the main website new changes uploaded after following the procedure.
And at the server: Two server created using docker (httpd) automatically by the Jenkins.One for the production team and other for testing team.
**We can also trigger Jenkins using github-hooks in github this will be create more fast automation.**