CI Stage Caching Issue

Hello,

I am relatively new to CI and have a basic two-stage CI configuration - build and deploy.

My build stage works as expected - installs composer dependencies, builds frontend assets, etc. and saves the untracked files to the pipeline artifacts.

My deploy stage is where I am getting stuck. My plan is to add a remote repository and push the build to that repository (required for our hosting provider). One of my steps in the job is to add the upstream remote to git. However, it says it already exists. If this is a fresh pull with artifacts extracted, how can there already be a second remote unless it is cached? That remote does not exist in the build job and there is no .git folder in the artifacts anyway.

I’ve tried to clear runner cache but that is as far as I got. Any ideas?

Did some further testing - I renamed the remote repository that I need in the .gitlab_ci.yml file and it succeeds the first time the job runs - I can add the remote. If I re-run the same job, it fails saying the remote already exists. This has to be some kind of cache issue.