【发布时间】:2018-04-03 08:53:24
【问题描述】:
从GitLab CI documentation 开始,Windows 支持 bash shell。
Supported systems by different shells:
Shells Bash Windows Batch PowerShell
Windows ✓ ✓ (default) ✓
在我的 config.toml 中,我尝试过:
[[runners]]
name = "myTestRunner"
url = xxxxxxxxxxxxxxxxxxx
token = xxxxxxxxxxxxxxxxxx
executor = "shell"
shell = "bash"
但是如果我的 .gitlab-ci.yml 尝试执行 bash 脚本,例如
stages:
- Stage1
testJob:
stage: Stage1
when: always
script:
- echo $PWD
tags:
- myTestRunner
然后从包含 GitLab 多运行器的文件夹中,我右键单击并选择“git bash here”,然后键入:
gitlab-runner.exe exec shell testJob
它无法解析$PWD,证明它实际上并没有使用 bash 执行器。 (Git bash 通常可以在 Windows 上正确打印出$PWD。)
Running with gitlab-runner 10.6.0 (a3543a27)
Using Shell executor...
Running on G0329...
Cloning repository...
Cloning into 'C:/GIT/CI_dev_project/builds/0/project-0'...
done.
Checking out 8cc3343d as bashFromBat...
Skipping Git submodules setup
$ echo $PWD
$PWD
Job succeeded
如果我推送一个提交,也会发生同样的事情,并且基于 Web 的 GitLab CI 终端会自动运行 .gitlab-ci 脚本。
如何在 Windows 上的 GitLab CI 中正确使用 Bash 终端?
【问题讨论】:
-
在实际提问之前,您应该搜索更多 SO。我开始回答您可能对 windows 与 unix 样式路径(
/c/gitlab...样式)有问题,或者您注意到它找不到 - 请检查stackoverflow.com/questions/41733406/… 我不想重复已经发生的事情已经写好了。