M. Bernd M. Bernd - 1 year ago 84
Git Question

Jenkins - How to clone just the last changed files from GitLab

Is there a possibility to let Jenkins clone only the changed files from GitLab instead of the whole repository?

Answer Source

Short answer: Don't do it, even if you find a way.

Here is why:

git clone is used when you don't have the repository locally and want to get one whole working copy of it.

git pull is used when you already have the repository cloned, and you only want to pull the newest changes.

git pull could potentially create merge conflicts, and dealing with those would require human intervention, and Jenkins is all about Automation, so git clone is preferred.

Jenkins deleting the repository and doing a fresh git clone also gives you the peace of mind that if your build works, it is because you have working code in your repository on GitLab and not because of something that Jenkins have saved from a previous build.