30

How to change the gitlab multi runner build path.

in my server it have /home/gitlab-runner/builds.

I want to change this path to my secondary HDD that is mounted in the same server.

3 Answers 3

31

You can change your runners build path by adjusting the config.toml. In the [[runners]] section add or change the builds_dir directory.

For further reference on runner configuration you can check out the documentation here.

6
  • As per your instruction I have changed the path but I got this error message while build mkdir: cannot create directory ‘/git/gitlab/git-runner/993865ac’: Permission denied.
    – Prem Anand
    Feb 6, 2017 at 10:15
  • @PremAnand The user running the gitlab-runner doesn't have proper permissions. You need to fix that.
    – Fairy
    Feb 6, 2017 at 11:09
  • Hi can you please tell me what permission I need to give to the gitlab runner and how to find which user is running gitlab runner.
    – Prem Anand
    Feb 6, 2017 at 12:03
  • 1
    Thank you so much. I fixed the issue by changing the owner and group permission for that folder to gitlab-runner:gitlab-runner and it is working perfectly. You really helped me a lot thank you so much fairy. You are genius
    – Prem Anand
    Feb 6, 2017 at 12:06
  • Thanks! By the way, this also requires gitlab-runner restart for the changes to take effect.
    – RAM237
    Sep 17, 2019 at 13:01
11

On macOS I was able to find one more way (can be helpful if you have many runners, I guess):

  1. Edit ~/Library/LaunchAgents/gitlab-runner.plist
    and modify the path under --working-directory to whatever you want

    e.g. from Terminal vim /Users/Me/Library/LaunchAgents/gitlab-runner.plist
    or using your favorite Text Editor

  2. Restart it for the changes to take effect

    gitlab-runner restart

1
  • 4
    This file is created by gitlab-runner install with the current working directory. Therefore you can also run gitlab-runner uninstall, cd <new directory> and gitlab-runner install to achieve the same effect.
    – Felix
    Jul 9, 2020 at 14:51
4

One may prefer to setup build directories globally.

In the file /etc/systemd/system/gitlab-ci-multi-runner.service there is a line

Environment="DAEMON_ARGS=run --working-directory /var/lib/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner"

So, you may change --working-directory /var/lib/gitlab-runner to whatever path you want, and wouldn't specify the --builds-dir on every new registered runner

Environment="DAEMON_ARGS=run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner"
1
  • 1
    After modify the file, according to the doc, you also need to execute systemctl daemon-reload && systemctl restart gitlab-runner.service.
    – Brainor
    May 29 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.