Last Updated: February 25, 2016
·
380
· parc_b

Make Jenkins tracking git updates

at jenkins server:

@jenkins $ mkdir /var/git/project.git
@jenkins $ cd /var/git/project.git
@jenkins $ git init --bare --shared

at origin:

@origin $ cd /var/git/project.git
@origin $ cp hooks/post-receive.sample hooks/post-receive
@origin $ vi hooks/post-receive


#!/bin/sh
#####
# hooks/post-receive
#####

MIRROR_HOST='jenkins@jenkins'
REPO_NAME=`pwd | perl -e '$t=<stdin>;$t=~ s!^.*/!!;print $t'`

git push --mirror ${MIRROR_HOST}:/var/git/${REPO_NAME}