Gitlab-runner 更改 builds_dir

Posted

技术标签:

【中文标题】Gitlab-runner 更改 builds_dir【英文标题】:Gitlab-runner change builds_dir 【发布时间】:2021-01-13 07:11:38 【问题描述】:

我在生产服务器上的默认 builds_dir 是 /root/builds/qL8eZYTH/0/faramarzqoshchi/testing_gitlab_runner/,我希望它是 /home/[domain_name]/public_html/test_build,用于我的测试阶段。 我已经在/etc/gitlab-runner/config.toml 中使用/home/[domain_name]/public_html/test_build 值定义了builds_dir 变量,但它仍然没有将testing_gitlab_runner 项目推送到/home/[domain_name]/public_html/test_build

我做的一切正确吗?这是将测试和生产等不同阶段推送到服务器的正确方法吗?

操作系统:Centos

【问题讨论】:

【参考方案1】:

根据the docs,您还必须启用custom_build_dir 设置,默认情况下仅对 docker 和 kubernetes 执行程序启用:

[runners.custom_build_dir]
  enabled = true

See here 了解有关此设置的更多信息。

另外你应该尝试设置变量$GIT_CLONE_PATH:

variables:
  GIT_CLONE_PATH: $CI_BUILDS_DIR/project-name

test:
  script:
    - pwd

GIT_CLONE_PATH 必须始终位于 $CI_BUILDS_DIR 内。 $CI_BUILDS_DIR 中设置的目录取决于 executor 和 runners.builds_dir 设置的配置。

这只能在运行器配置中启用 custom_build_dir 时使用。这是 docker 和 kubernetes 执行器的默认配置。

Source


所以在你的具体情况下,我会在你的config.toml 中尝试这个:

builds_dir = "/home/[domain_name]/public_html/test_build"

[runners.custom_build_dir]
  enabled = true

并将其添加到您的 .gitlab-ci.yml 的顶部:

variables:
  GIT_CLONE_PATH: $CI_BUILDS_DIR/testing_gitlab_runner

【讨论】:

以上是关于Gitlab-runner 更改 builds_dir的主要内容,如果未能解决你的问题,请参考以下文章

更改 Gitlab CI Runner 用户

gitlab-runner 随机运行为 root 而不是用户 gitlab-runner

gitlab-runner的无权限问题

Gitlab-runner 安装

安装gitlab-runner

gitlab-runner安装