Friday, January 18, 2019

#Throwback: A batch script to clone or update Project from a Git repository

Background:The use-case behind this was that we could not checkout our project from Git repository in Jenkins for reasons I could not remember. I'm just publishing this here as an archive for future reference in case I encounter something of the same nature.
  1. There should be curl in the system to verify the URLs
  2. Set the variables, set proxy depending on IP of the Jenkins slave. We had slaves within a certain subnet which needs proxy for them to be able to connect to our Git repositories.
  3. Perform connection checks 
  4. Proceed with clone if project is not yet existing in the machine, update if already existing 
  5. Create backup of successful clone/update