首页 > 其他分享 >gitlab runner 使用摘要

gitlab runner 使用摘要

时间:2023-11-24 14:59:03浏览次数:36  
标签:摘要 run runner gitlab -- docker GitLab

参考文档
GitLab Runner runs the CI/CD jobs that are defined in GitLab
GitLab Runner is open-source and written in Go. It can run as a single binary and has no language-specific requirements.
After you install GitLab Runner, you must create and register runners with your GitLab instance. This instance can be self-managed, or you can use GitLab.com. You can also follow the tutorial, Create, register, and run your own project runner.

General GitLab Runner Docker image usage

GitLab Runner Docker images (based on Ubuntu or Alpine Linux) are designed as wrappers around the standard gitlab-runner command, like if GitLab Runner was installed directly on the host.

GitLab Runner command that normally would be executed as

gitlab-runner <runner command and options...>

can be executed with

docker run <chosen docker options...> gitlab/gitlab-runner <runner command and options...>

For example

docker run --rm -t -i gitlab/gitlab-runner --help

NAME:
   gitlab-runner - a GitLab Runner

USAGE:
   gitlab-runner [global options] command [command options] [arguments...]

VERSION:
   16.5.0 (853330f9)

(...)

Use local system volume mounts to start the Runner container

#!/bin/bash

export GITLAB_RUNNER_HOM=/srv/gitlab-runner

docker run \
    -d \
    -v $GITLAB_RUNNER_HOME/etc/config:/etc/gitlab-runner \
    -v /var/run/docker.sock:/var/run/docker.sock \
    --privileged \
    --network bridge \
    --add-host gitlab.example.com:172.17.0.2 \
    --name gitlab-runner \
    --link gitlab:gitlab \
gitlab/gitlab-runner:latest  run --user root --working-directory /root

Update configuration

If you change the configuration in config.toml, you might need to restart the runner to apply the change. The config.toml is the configuration file that you use to configure runners, and is created when you register a runner.

You should restart the whole container instead of using gitlab-runner restart

docker restart gitlab-runner 

SELinux

Some distributions (CentOS, Red Hat, Fedora) use SELinux by default to enhance the security of the underlying system

Special care must be taken when dealing with such a configuration.

  1. If you want to use the Docker executor to run builds in containers, you need access to /var/run/docker.sock. However, if SELinux is in enforcing mode, you see a Permission denied error when you’re accessing /var/run/docker.sock. Install selinux-dockersock to resolve this issue.
  2. Make sure that a persistent directory is created on host: mkdir -p /srv/gitlab-runner/config.
  3. Run Docker with :Z on volumes:
docker run -d --name gitlab-runner --restart always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner:Z \
  gitlab/gitlab-runner:latest

Registering runners

参考文档
Introduced in GitLab Runner 15.0, a change to the registration request format prevents the GitLab Runner from communicating with GitLab 14.7 and earlier. You must use a GitLab Runner version that is appropriate for the GitLab version, or upgrade the GitLab application

Runner registration is the process that links the runner with one or more GitLab instances. You must register the runner so that it can pick up jobs from the GitLab instance.

  1. Run the register command

    sudo gitlab-runner register
    
    • Enter your GitLab URL
    • Enter the runner authentication token
    • Enter the runner authentication token
    • Enter the type of executor
  2. You can also use the non-interactive mode to use additional arguments to register the runner

    sudo gitlab-runner register \
    --non-interactive \
    --url "https://gitlab.com/" \
    --token "$RUNNER_TOKEN" \
    --executor "docker" \
    --docker-image alpine:latest \
    --description "docker-runner"
    

生成runner后, 生成的 runner 配置参考

配置文件明细参考

配置文件demo

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "blog-runner"
  url = "http://gitlab.example.com:8980"
  token = "t1ixUk811QUySmuzCeMq"
  clone_url="http://172.17.0.2:8980/"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    pull_policy = "if-not-present"
    shm_size = 0
  • pull_policy

    • always: Pull an image even if a local image exists. Default
    • if-not-present: Pull an image only when a local version does not exist
    • if-not-present: Pull an image only when a local version does not exist
  • clone_url

    • Overwrite the URL for the GitLab instance. Used only if the runner can’t connect to the GitLab UR
  • How clone_url works

    When the GitLab instance is available at a URL that the runner can’t use, you can configure a clone_url.

    For example, a firewall might prevent the runner from reaching the URL. If the runner can reach the node on 192.168.1.23, set the clone_url to http://192.168.1.23.

    If the clone_url is set, the runner constructs a clone URL in the form of http://gitlab-ci-token:[email protected]/namespace/project.git

标签:摘要,run,runner,gitlab,--,docker,GitLab
From: https://www.cnblogs.com/zakun/p/gitlab-runner.html

相关文章

  • UI自动化测试神器:RunnerGo测试平台
    可以直接进入官网下载开源版或点击右上角体验企业版体验 RunnerGoUI自动化平台RunnerGo提供从API管理到API性能再到可视化的API自动化、UI自动化测试功能模块,覆盖了整个产品测试周期。RunnerGoUI自动化基于Selenium浏览器自动化方案构建,内嵌高度可复用的测试脚本,测试团队......
  • Gitlab Docker 使用摘要
    官方文档:https://docs.gitlab.com/ee/install/docker.html#expose-gitlab-on-different-ports设置本地目录设置环境变量GITLAB_HOMEexportGITLAB_HOME=/srv/gitlab安装启动脚本start.sh#!/bin/bashexportGITLAB_HOME=/srv/gitlabsudodockerrun--detach......
  • gitlab项目创建后项目组成员不能提交代码
    提交报错如下:git.exepush--progress"origin"main:mainEnumeratingobjects:4,done.Countingobjects:100%(4/4),done.Deltacompressionusingupto8threadsCompressingobjects:100%(2/2),done.Writingobjects:100%(3/3),294bytes|294.00KiB/s,......
  • gitlab/github 设置 SSH
    最近项目要部署到另一台机器上,故要重新gitclone一下一开始只是简单的设置config里的user.name和user.email,以为就可以clone(邮箱账户拥有项目的权限) 设置configuser.name和email的方法gitconfig--globaluser.name"YourUsername"gitconfig--globalus......
  • 《写给大家看的项目管理书》摘要
     书名写给大家看的项目管理书作者【美】GregoryM.Horine出版社人民邮电出版社阅读时间2023.11.17-11.19项目经理的关键技能项目管理基础知识:包括办公套装软件以及使用项目管理软件的技能。企业管理技能:如预算、财务、采购、组织......
  • Jenkins+.net Care7+GitLab+docker desktop 实现自动化部署(完结)
    1.上一篇文章大家各种环境搭建好了之后2.创建一个仓库开启远程访问权限3.开启gitlab允许对本地网络发送请求这个主要为webhook做准备的,否则gitlab不允许项目添加本地网络的webhook以管理员身份登录gitlab 4.没有这个的话得下载插件可以去   下载这几个插件就可以......
  • Jenkins+.net Care7+GitLab+docker desktop 实现自动化部署(1)
    1.首先在电脑上安装jenkins+java17这个不做过多讲解网上教程都有2在docker安装GitLab查看版本dockersearchgitlab拉取指定版本:dockerpulltwang2218/gitlab-ce-zhdockerrun-d#后台运行,全称:detach-p8443:443#将容器内部端口向外映射......
  • windows 配置 SSH 连接 GitLab,实现免密登录
    第一步,生成秘钥并配置到GitLab上(一路回车),这里的邮箱是注册邮箱ssh-keygen-trsa-C"[email protected]"第二步,这时会在上面的目录生成很多文件,我们只需要id_rsa.pub文件,使用记事本复制里面的内容 第三步,在 GitLab的偏好设置里面找到SSH密钥,将id_rsa.pub......
  • 《全网最细-深度解析 Istio Ambient Mesh 流量路径》摘要
    ----NodeA首次上行--------APREROUTING-jztunnel-PREROUTING-Aztunnel-PREROUTING-ptcp-mset--match-setztunnel-pods-ipssrc-jMARK--set-xmark0x100/0x100-Aztunnel-PREROUTING-mmark--mark0x100/0x100-jACCEPTfromallfwmark0x100/0x100lookup101101......
  • Knative Event gitlab source
    服务说明本地gitlab信息ip地址:192.168.174.108httpport:8080域名:codo.wgs.comkservice-event-display信息istio-ingressgateway对外地址:192.168.174.249kservice-event-display对外域名:gitlabsource.wgs.com域名解析:gitlabsource.wgs.com-->192.168.174.249......