In this project i tried to automate everything development to production level in simple webserver. Steps that followed
- Git local and github repo
- create 3 jobs (main_server, testing, merge) as follows
- Add hooks given below
- Commit from any branch either master or dev1 respectivly it will run job( ie if master commit then main_server will bulid and if dev1 commit then test will build)
- Run merge Job after testing either using bash script or using url or manually building
#!/bin/bash
echo "git push after commit "
if [ git rev-parse --abbrev-ref HEAD
== "dev1" ];
then
git push -u origin dev1
curl --user "admin:redhat" http://192.168.43.243:8080//job/test/build?token=[add token here]
if [ git rev-parse --abbrev-ref HEAD
== "master" ];
then
git push -u origin master
curl --user "admin:redhat" http://192.168.43.243:8080//job/main_server/build?token=[add token here]
fi