Skip to content

Instantly share code, notes, and snippets.

@ezarko
Last active November 13, 2020 15:32
Show Gist options
  • Save ezarko/e8c4f31900b4e0e668c7be8c32acf5bd to your computer and use it in GitHub Desktop.
Save ezarko/e8c4f31900b4e0e668c7be8c32acf5bd to your computer and use it in GitHub Desktop.
Creates a "reference repository" on a Jenkins slave to speed up build times.
#!/bin/bash
# Creates a "reference repository" on a Jenkins slave to speed up build times.
# Assumes that you will clone using HTTPS and enter username/password, then
# Jenkins will use an SSH key in the future.
#
# Works with Jenkins and GitLab. For other applications your mileage may vary.
REPO_SERVER=osn-git.us.oracle.com
REPO_PATH=ccs/caas.git
CACHEDIR=~/gitcaches
################################################################################
REF=$CACHEDIR/${REPO_PATH##*/}
REF=${REF%.git}.reference
mkdir -p $CACHEDIR
git clone --mirror https://$REPO_SERVER/$REPO_PATH $REF
(cd $REF; git remote set-url origin git@$REPO_SERVER:$REPO_PATH)
echo "Git reference path: $REF"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment