I have a parent child trigger based pipeline. I have enabled build_dir override and providing clone path in my .yml as follows. Also please note that some other dev is also doing some experiment simultaneously with same runner but having git strategy none and checking out in a specific dir.
In config.toml
[runners.custom_build_dir]
enabled = true
builds_dir = "//opt/app/abc"
In parent yml
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_PATH/project/pipeline
stages:
- build
- trigger-services
trigger_s1:
interruptible: false
stage: trigger-services
needs: [build]
trigger:
include: s1.gitlab-ci.yml
strategy: depend
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
paths:
- abc/**/*
allow_failure: false
In s1.yml
---------------------
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_PATH/project/pipeline
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline"
stages:
- test
test:
stage: test
script:
- echo "Running the Unit Test Cases!"
Now issues I am facing are
1- I can see clone dir is keep on changing in multiple runs. for example it intermittently picking /home/abc and some time /opt/abc/
2- Another issue is when it is picking right patch in parent job , child pipeline job is throwing error like
ERROR: Job failed: the GIT_CLONE_PATH="correct_path" has to be within "a_random_path"
Is gitlab is chaching these build and clone path somewhere? is there any way I can clean/reset it before my execution?
3- what is the best way to achieve this pipeline to work that is passing correct repo to child jobs?
So the problem was with runners working dir. If you start runner as a non root user and dont pass any working dir as arg it will take current dir as working dir. On pipline trigger boom!!! it is expecting your clone path should be with that runner's working dir. Fix- run the runner from builds_dir or pass it as a working dir arg.
gitlab-runner run --working-directory=‘/opt/app/abc'