Gitlab-runner 修改默认的builds_dir并使用custom_build_dir配置

发布于:2025-02-11 ⋅ 阅读:(46) ⋅ 点赞:(0)

参考链接
builds_dir 默认路径
custom_build_dir runner配置
Custom build directories

1. 说明

涉及到两部分:

    1. 修改默认的builds_dir
    1. 启用custom_build_dir

2. 实操(以docker执行器为例)

2.1 修改默认的builds_dir

2.1.1 调整gitlab-runner的配置文件
...
...
[[runners]]
  ...
  ...
  executor = "docker"
  builds_dir = "/root/codes"
  ...
  ...
gitlab-runner  verify #校验配置文件
2.1.2 CI文件

在这里插入图片描述

image: busybox:latest
build1:
  stage: build
  script:
    - echo $CI_BUILDS_DIR
    - echo "Do your build here"
    - sleep 600s
  tags:
    - vm100

2.1.3 runner中查看builds_dir目录

在这里插入图片描述

2.2 启用custom_build_dir

2.2.1 调整gitlab-runner的配置文件
[[runners]]
  ...
  ...
  executor = "docker"
  builds_dir = "/root/codes"
  [runners.custom_build_dir]
    enabled = true
  ...
  ...
gitlab-runner  verify #校验配置文件
2.2.2 CI文件
image: busybox:latest

variables:
  GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_NAME-$CI_COMMIT_BRANCH
build1:
  stage: build
  script:
    - echo $CI_BUILDS_DIR
    - echo "Do your build here"
    - sleep 600s
  tags:
    - vm100

在这里插入图片描述

2.2.3 runner中查看builds_dir目录

在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到