Setting GIT_CLONE_PATH as a subdirectory of CI_PROJECT_DIR in the CI
I have a repo named main which needs to checkout another repo called sub. I need the following directory structure:
+ root
+- main
+- sub
+- build
I thought I could solve this with setting GIT_CLONE_PATH to $CI_PROJECT_DIR/main, but unfortunately this is not how CI_PROJECT_DIR works.
I have solved this with the following:
build:gcc7:
stage: build
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/main/main # I can't use $CI_PROJECT_DIR here.
script:
- cd ..
- export CI_TOP_DIR=$(pwd)
- if [ -d "$CI_TOP_DIR/sub" ]; then rm -Rf $CI_TOP_DIR/sub; fi
- if [ -d "$CI_TOP_DIR/build" ]; then rm -Rf $CI_TOP_DIR/build; fi
- git clone --depth 1 <url> $CI_TOP_DIR/sub
- mkdir build
The problem is that I end up creating files outside of the CI_PROJECT_DIR which seems messy because I have to manually delete stale files and I cannot use the cache mechanism. Is there a clean way of doing this?