Jenkins and Github Integration using PollSCM, Job Chaining and Remote Triggers, git hooks.

ANKUR DHAKAR
May 6, 2020

--

Integrating Jenkins with local git hooks and deploying the source code on docker containers using PollSCM triggers.

Three jobs are needed for simulating this project.

  1. Job 1

For deploying testing environment on the top of docker using git hooks(post-commit) when any commits are done from the featured branch( other than master(main branch)) and the job is scheduled using PollSCM.

git hooks => post-commit script vi .git/hooks/post-commit

#!/bin/bash echo “First and then Post Commit Tasks are started”
git fetch
git push
echo git push is done to the current Remote Branch”
#echo “remote Build Trigger using jenkins URL”
#curl — user “username:password” <
http:///job/job3/build?token=TOKEN>

Job1

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

2. Job 2

For deploying Production environment only when there is some change in master branch and scheduled using PollSCM.

Job2

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

3. Job 3

For merging the featured branch to the master(main) branch and triggered remotely using http:///job/job3/build?token=TOKEN with credentials of Jenkins users only and also scheduled using PollSCM.

Job3

This how we can use Jenkins Tool in a great way to automate our tasks.

P.S.- Docker image used in this environment is Apache HTTPD Docker image with tag httpd:latest. It can be pulled from hub.docker.com.
#docker pull httpd:latest

Github repo url:-
https://github.com/A4ANK/jenkins_github_integration_1.0

--

--

ANKUR DHAKAR
ANKUR DHAKAR

Written by ANKUR DHAKAR

I am pursuing masters in computer science from BITS Pilani Hyderabad Campus, and passionate about Linux administration and security, Cloud Computing, and CNCF.

No responses yet