Skip to content

Gitlab runner uses $HOME env variable to setup git for repo fetching

Gitlab runner v11.x as oposed to gitlab 10.x does repo cloning by inderectly using $HOME envariable ( most likely by git configure command). That causes issue when .gitlab-ci script also sets this variable into not yet cloned project directory. e.g

variables:
 HOME: $CI_PROJECT_DIR

in such case script that tries to clone repository will fail as home is set to not yet existing folder (while some internal script probably tries to use "git config") that causes following crash in build

error: could not lock config file /builds/project_dir/.gitconfig: No such file or directory
/bin/bash: line 73: cd: /builds/project_dir: No such file or directory

Setting home to project serves a purpose of improved cacheing - some tools use home to setup caches (and these tools are really hard or impractical to reconfigure otherwise).

In short cloning script should not relay on environmental configuration of the build that is yet to happen.

Edited by 🤖 GitLab Bot 🤖