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
27concurrent
表示并发任务数量volumes
, 类似 docker 里的-v
参数,machine_path:docker_path
network_mode = "host"
, 表示使用宿主机的网络,防止一些域名无法解析的问题- 其它字段可参考
- 运行
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
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
-> 参考
编辑此页 (opens new window)
更新于: 2021-06-17 17:23