GitLab-CI
配置
Linux
可以通过docker-compose进行部署,并且将配置文件等暴露出去:
services:
fugan-ci-runner:
container_name: fugan_project_ci_runner
image: inner-harbor.faceunity.com/retalking/fugan:ci_runner
environment:
- TZ=Asia/Shanghai
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility,video # all
restart: always
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
shm_size: 16G
network_mode: bridge
# For release the base image.
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/etc/gitlab-runner
- /usr/bin/docker-compose:/usr/bin/docker-compose
- ${HOME}/.docker:/root/.docker然后添加gitlab的known_hosts:
#!/bin/bash
docker-compose exec -it fugan-ci-runner /bin/bash -c "ssh-keyscan 192.168.0.118 >> /root/.ssh/known_hosts"然后添加runner等操作可以通过脚本来做:
#!/bin/bash
# 前提是上面的gitlab runner已经启动了
docker-compose exec -it fugan-ci-runner gitlab-runner registerWindows
下载gitlab runner的可执行程序,随后配置,windows下该程序是以service的方式跑的
# 重启程序
Restart-Service gitlab-runner问题
windows下的gitlab runner git行为异常
现象:windows的gitlab runner无法正常git submodule update --init --recursive,而在宿主机上是可以正常做到的。
问题分析流程:看起来是gitlab runner没有正常识别宿主机的证书路径下的文件~/.ssh,也就是说gitlab runner执行的环境(环境变量)和宿主机上正常执行的有差异。那么在脚本中尝试打印一下%HOME%、%USERPROFILE%等,发现%HOME%环境变量为空,印证了我想想法。
解决办法:
- 尝试在
系统环境变量中增加%HOME%。(问题解决了) - 并且注意到系统环境变量会影响到gitlab runner,所以需要谨慎开启系统代理。