I am new to GitLab coming from TFS aka Azure DevOps, on-premise using TFVC so am also new to Git.
I have a need to use multiple repos in a single CI job. One example is that test data is in its own repo shared by many projects. So the test job in a repo depends on the build job so it gets its artifacts, but then needs to clone or pull the test data repo before running the tests.
I don’t know if it matters but I’m using a Windows gitlab runner to build C# code many libraries and several WPF applications. Thus my CI scripts are written in PowerShell (so $AnyText is a variable in code below), and I have flushed out a number of helpful functions to make doing things much easier. The one I’m struggling with is the one to clone/pull extra repos.
Following GitLab documentation I managed to construct a valid URLs for any project/repo. I want to do exactly the same thing the runner does for the project/repo the CI job is coming from for the other extra repos. Reading carefully from this GitLab document:
And assuming the defaults.
I produced this command for the initial clone:
git clone --depth $Env:GIT_DEPTH -b $Branch $RootRepoURL/$Repo.git “$FullFolder”
And this series of commands for updating local repo on the runner:
git clean -ffdx
git fetch $RootRepoURL/$Repo.git $Branch --depth $Env:GIT_DEPTH --prune --quiet
git checkout -B $Branch
If I logon to the runner and clean all the build stuff off, then the next build and test works correctly, so the clone of the extra repos works fine. But if I push changes to the repo(s) and then build/test again. I can see that the files are not updated for the other extra repos, they’re still the ones from the clone.
The CI jobs will be run for every push of every different branch, as well as for merges back to main, so I need it to handle all that bouncing around.
Because it isn’t working correctly right now, I temporarily have it deleting the other/extra repos before hitting the script to clone/pull so that it always clones new. So I’m working but it is doing a LOT of repeated cloning of repos thus is drastically inefficient.
Does anyone know the actually list of Git commands a runner uses when updating a repo and switching branches?