BluePen BluePen
  • Jenkins
  • OS
  • 算法
随笔
分类
标签
归档
关于
留言板
GitHub (opens new window)

Alex

一个好人
  • Jenkins
  • OS
  • 算法
随笔
分类
标签
归档
关于
留言板
GitHub (opens new window)
  • shutdown
  • gitlab-ci
    • summary
    • tips
    • example
    • 参考
  • Gitlab Merge Request API
  • vscode-plugin
  • best-practice
Alex
2021-06-17
目录

gitlab-ci

gitlab-ci 的使用还是很方便的,配置好后,使用时维护仓库内的 .gitlab-ci.yaml配置文件即可。

-> summary

  • 安装客户端 gitlab-runner服务
  • 注册 runner关联到 gitlab仓库
  • 也可以全局配置好多个共用的 runner,则后续可直接编写 .gitlab-ci.yaml配置文件即可

-> tips

  • 创建专用用户 gitlab-runner来启动客户端 runner服务
    • eg: 可直接使用二进制文件安装 linux-manually (opens new window)
  • 注册 runner时的 executor 选 docker即可
  • 所有的 runner配置均在 /etc/gitlab-runner/config.toml, 修改后自动生效
    # config.toml
    concurrent = 1
    check_interval = 0
    
    [session_server]
      session_timeout = 1800
    
    [[runners]]
      name = "ci"
      url = "http://gitlab.example.local"
      token = "zxpsJypevjoEn3AUDrEP"
      executor = "docker"
      [runners.custom_build_dir]
      [runners.cache]
        [runners.cache.s3]
        [runners.cache.gcs]
        [runners.cache.azure]
      [runners.docker]
        tls_verify = false
        image = "node:14-alpine"
        privileged = false
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/home/gitlab-runner/output/:/cache"]
        network_mode = "host"
        shm_size = 0
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    • concurrent 表示并发任务数量
    • volumes, 类似 docker 里的 -v参数,machine_path:docker_path
    • network_mode = "host", 表示使用宿主机的网络,防止一些域名无法解析的问题
    • 其它字段可参考
      • advanced-configuration (opens new window)
      • advanced-configuration (opens new window)
  • 运行 gitlab-runner verify --delete 可删除已经断开的 runner
  • 提交信息里添加 [ci skip] 或者 [skip ci](大小写不敏感)可不触发构建

-> example

# .gitlab-ci.yaml
image: node:14-alpine

cache:
  paths:
    - node_modules/
    - .yarn/

dev_build:
  stage: build
  script:
    - node -v
    - yarn -v
    - yarn config set registry http://mirrors.cloud.tencent.com/npm/
    - yarn config set proxy  http://172.24.16.166:8080
    - yarn config set https-proxy  http://172.24.16.166:8080
    - yarn install --pure-lockfile --cache-folder .yarn
    - yarn build
    - tar -czf dist.tar.gz ./dist
  artifacts:
    paths:
      - dist.tar.gz
    expire_in: 1 week
  only:
    - stage
  tags:
    - ci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

-> 参考

  • install runner (opens new window)
  • register runner (opens new window)
  • runner configuration (opens new window)
  • gitlab-ci.yaml (opens new window)
编辑此页 (opens new window)
更新于: 2021-06-17 17:23
shutdown
Gitlab Merge Request API

← shutdown Gitlab Merge Request API→

Copyright © 2019-2022 | yxxy | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式