dir*_*k.z 2 python gitlab gitlab-ci gitlab-ci-runner jupyter-notebook
我想用我的管道运行我的 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
Run Code Online (Sandbox Code Playgroud)
错误:
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
Run Code Online (Sandbox Code Playgroud)
当我在 cmd 中尝试相同的命令时,一切正常。
根据您的日志,您正在使用shell执行程序。这将在您的本地 shell 上运行命令,就像您自己一样。问题是运行程序不使用您的操作系统环境变量,因此您需要将python、git等路径添加到运行程序的路径环境变量中。
执行此操作的最佳方法是在运行程序environment的. 该文件可以位于或root中。此 StackOverflow线程展示了如何执行此操作。请阅读 高级配置以获取更多信息。[[runners]]config.tomlconfig.toml/etc/gitlab-runner/~/.gitlab-runner/
如果您想下载并使用自定义 docker 镜像(例如 ),python:3.9则需要使用Docker Executor。