Gitlab Runner windows环境下解决中文乱码导致无法拉取含有中文的tag
环境
- 系统 windows10
- CPU架构AMD64
- gitlab版本: GitLab Enterprise Edition 13.12.0-ee
- gitlab runner版本: 17.10.1
失败现象
fatal: couldn't find remote ref refs/tags/浣犵殑
Running with gitlab-runner 17.10.1 (ef334dcc)
on dev-gaoyu Chob-M8t, system ID: s_172a3486fe3d
Preparing the "shell" executor
00:00
Using Shell (powershell) executor...
Preparing environment
00:00
Running on MYPC...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/gitlabtest/.git/
fatal: couldn't find remote ref refs/tags/浣犵殑
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 128
解决方法
在执行启动gitlab runner服务之前,先切换代码页
chcp 65001
./gitlab-runner.exe run
网上其它方法(失败)
- 在gitlab runner的config.toml中 增加 pre_clone_script = "chcp 65001"
- 在.gitlab-ci.yml的script中增加 "chcp 65001"
个人理解
似乎在Reinitialized existing Git repository这一步就出错了,此时还没有机会运行chcp 65001命令
通过先执行 chcp 65001 再启动gitlab runner,可以避免顺序问题