DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Git Cache for Continuous Integration Jobs

Git Cache for Continuous Integration Jobs

A quick code snippet on solving a large Git repository clone issue.

Mika Andrianarijaona user avatar by
Mika Andrianarijaona
·
Mar. 08, 16 · DevOps Zone · Code Snippet
Like (4)
Save
Tweet
3.61K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, I will explain how I solved a large Git repository clone issue we had during our continuous integration job.

The fact is that we have a Cordova project using multiple plugins. Most of these plugins are stored in git repositories and some of them or their dependencies are really large. This can slow our job execution or even make it fail (due to timeout) as it depends on our internet connection..

I decided to find a way to "cache" repository so the build jobs wouldn't use internet connection each time they need to clone the plugin repository without changing plugins files.

The solution I found was to use our  locally hosted GitLab as a mirror for the large repository and force Git to use it using the Git configuration "insteadOf".

I created a new repository in our gitlab to host the large plugin repository and I cloned it's content from remote location once. I then added the following configuration for git inside the CI job runner machine:

git config --global url."<url of local gitlab mirror>".insteadOf "<url of primary repository>"

Now I just need to regularly update the local mirror with a simple cron job for example. The Gitlab Enterprise Edition can also automatically update it's repository from remote origin.

The result is just impressive: one job that could take more than an hour before a large repository clone will now execute in less than 10 minutes.

CI Job successes

CI/CD career Git Integration Cache (computing)

Published at DZone with permission of Mika Andrianarijaona. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Modernize Legacy Code in Production: Rebuild Your Airplane Midflight Without Crashing
  • Servlets Listeners Introduction and Examples
  • Maven Tutorial: Nice and Easy [Video]
  • Top 7 Automated Testing Trends of 2022

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo