我想用我的管道运行我的 Jupyter 笔记本。为此,我需要 runipy。要在 gitlab runner 上安装 runipy,我需要 python。但是当我想运行 .gitlab-ci.yml 脚本时,它会因为无法识别 python 而卡在打印 python 版本上。
.gitlab-ci.yml:
image: python:3.9
before_script:
- python -V
- pip install runipy
错误:
Running with gitlab-runner 13.3.1 (738bbe5a)
on JavaUnitTestRunner vr_SgzNd
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:01
Running on DESKTOP-DJVC49J...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Gitlab-Runner/builds/vr_SgzNd/0/I438220/pharma/.git/
Checking out 65a225c0 as pipeline...
git-lfs/2.9.2 (GitHub; windows amd64; go 1.12.7; git 0274d856)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:02
$ python -V
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\WINDOWS\TEMP\build_script377697220\script.ps1:195 char:1
+ python -V
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ERROR: Job failed: exit status 1
当我在 cmd 中尝试相同的命令时,一切正常。
答案 0 :(得分:1)
根据您的日志,您正在使用 shell
执行程序。这将在您的本地 shell 上运行命令,就像您自己一样。问题是运行程序没有使用您的操作系统环境变量,因此您需要将您的 python
、git
等路径添加到运行程序的路径环境变量中。
执行此操作的最佳方法是在跑步者的 environment
的 [[runners]]
部分的 config.toml
变量中明确配置路径变量。 config.toml
文件可以位于 /etc/gitlab-runner/
、~/.gitlab-runner
或 /
根目录中。这个 StackOverflow thread 展示了如何做到这一点。请阅读Advanced Configurations了解更多信息。
如果您想下载和使用自定义 docker 镜像,例如 python:3.9
,您需要使用 Docker Executor。