1

I am using gitlab-runner for my CI tasks on centos 7. I have to build the project and then run it.

In my different xml and .sh files I have different paths which refer to some other files in some directory. For example a file can have path like /home/gitlab-runner/builds/zzzzz/0/some_folder/run_script.sh

But each time gitlab-runner starts building the project in a different path like /home/gitlab-runner/builds/zzzzz/1/. It causes issues, I have to change all the paths in files.

I want it to build always in the same directory as /home/gitlab-runner/builds/zzzzz/0/.

Any help will be appreciated.

Muhammad Saleem
  • 51
  • 1
  • 10

1 Answers1

3

Gitlab injects environment variable CI_PROJECT_DIR with your project root directory

e.g. $CI_PROJECT_DIR/script/foo.sh

iTech
  • 18,192
  • 4
  • 57
  • 80
  • This variable can be used in gitlab-ci.yml script. What I have is different paths in my project code files. So I need to use method to update those paths dynamically. Instead of giving fixed path like "/home/gitlab-runner/builds/zzzzz/0/some_folder/run_script.sh". These paths are in c language scripts or in .xml files. these are not in .yml file. – Muhammad Saleem Jun 05 '20 at 12:46
  • These are general shell environment variable, you have access to them from any process not just the yaml file – iTech Jun 05 '20 at 16:27