我想指定一个创建狮身人面像html文档的GitLab作业。
我正在使用Python 3高山图像(无法确切指定哪个图像)。
.gitlab-ci.yml
中的构建阶段如下:
pages:
stage: build
tags:
- buildtag
script:
- pip install -U sphinx
- sphinx-build -b html docs/ public/
only:
- master
但是,管道失败:sphinx-build: command not found
。 (与make html
相同的错误)
根据This Tutorial,我的.gitlab-ci.yml
应该或多或少正确。
我在做什么错?这个问题与我使用的高山图像有关吗?
答案 0 :(得分:2)
正如@Yasen正确指出的那样,sphinx-build
中未包含指向$PATH
的路径。但是,在command
之前添加sphinx-build
并不能解决我的问题。
无论如何,我在运行日志中找到了解决方案:pip install -U sphinx
的输出产生了以下警告:
WARNING: The scripts sphinx-apidoc, sphinx-autogen, sphinx-build and sphinx-quickstart are installed in 'some/path' which is not on PATH.
所以我在export PATH="some/path"
的脚本步骤中添加了.gitlab-ci.yml
:
script:
- pip install -U sphinx
- export PATH="some/path"
- sphinx-build -b html docs/ public/
答案 1 :(得分:1)
最可能的原因是$PATH
不包含指向sphinx-build
的路径
command
尝试一下:
pages:
stage: build
tags:
- buildtag
script:
- pip install -U sphinx
- command sphinx-build -b html docs/ public/
only:
- master
GitLab
跑步者的跑法不同由于GitLab CI
使用runners
,因此runner
的shell配置文件可能与常用的不同。
因此,您的运行程序可能在没有声明$PATH
的情况下配置到包含sphinx-build
的目录中
请参见this explanation:
问题在于,Bash根据其认为所在的外壳类型从不同文件中获取资源。对于“交互式非登录外壳”,其读取为.bashrc,而对于“交互式登录外壳”,其读取为来自.bash_profile,.bash_login和.profile的 first (仅限)。没有理智的理由应该如此。这只是历史。
command
是什么意思?由于我们不知道sphinx-build
的安装路径,因此您可以使用诸如which
,type
等命令。
根据这个很好的答案(shell - Why not use "which"? What to use then? - Unix & Linux Stack Exchange,作者建议使用command <name>
或$(command -v <name>)
答案 2 :(得分:1)
命令pip install -U sphinx
是否成功? (您应该能够从CI作业日志中得知。)
如果是这样,您可能需要指定Yas所说的sphinx-build
的完整路径。
如果未成功,则应该对Sphinx的安装进行故障排除。