I have a GitHub repo that's big and contains several independently build-able bits. If I configure Jenkins with a job (or two) for each of these, I end up with having to pull gigabytes of data multiple times (one clone of the repo for each job).
This takes both diskspace and bandwidth.
What I'd like to do is have "Refresh local repo" job that clones github once, then configure each of the jobs to clone themselves from that repo, and build. Then by setting up the sub-jobs as dependent builds, I can run "Refresh local repo", have it pull all the latest stuff from GitHub, then have each of the builds run.
So far I've got the "Refresh local repo" working - it clones successfully, and if I go to the workspace, I see that it has the HEAD commit of origin/master.
The problem is the other jobs - these don't seem to be picking up updates. Here's how I've got one of them configured:
Git Repository URL file:////Users/malcolmbox/.jenkins/jobs/Refresh Local repo/workspace Branches to build master
Instead of this updating to the latest commit, it's stuck several days in the past.
How can I get it to pull the tip and do the right thing?
To clarify: the .../Refresh Local repo/workspace has commit 6b20268389064590147d5c73d2b6aceb6ba5fe70 submitted 28/3
The dependent build, after running a build (so presumably doing a git clone/pull step) is checked out to 79a25992cc192376522bcb634ee0f7eb3033fc7e submitted 26/3 - so it's a couple of days behind.
Access local git repository in Jenkins docker container To mount your local git repository folder to a Jenkins container run the container with an additional -v or --volume flag. The basic docker run statement from the official docker image documentation would then look like. The :ro option is optional.
Checking out more than one repo at a time in a single workspace is possible with Jenkins + Git Plugin (maybe only in more recent versions?). In section "Source-Code-Management", do not select "Git", but "Multiple SCMs" and add several git repositories.
However, git is great for working with several repositories. These additional repositories can be stored locally, or accessed via network connection.
Configuring Git with Jenkins Now open your project and go to configure. Step 2: Give the repository Url in Source Code Management, repository Url can be fetched by clicking on clone and download option of Github and you have to select the SSH Url. Also, add credentials there of Jenkins.
If you open the job configuration and click on the Advanced button of the git SCM configuration, you will see a place to specify "Path of the reference repo to use during clone (optional)".
If you have a local clone of your repository, add the path to the reference repo field.
Git will then use the local clone and share most of the git objects on the disk and pulling from github only what is missing from the local clone resulting in lightning fast clones and saved disk space.
Or is this exactly how you have configured your job and it is not picking up latest commits? If that is so, please provide more details. Consider publishing your job configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With