简体   繁体   English

使用gitlab runner时Python不被识别为命令

[英]Python not recognised as command when using gitlab runner

I am trying to set up continuous integration on a gitlab repository. 我正在尝试在gitlab存储库上建立持续集成。

I have added the following gitlab-ci.yml file: 我添加了以下gitlab-ci.yml文件:

stages:
 - test


test:
 image: python:3.7
 script:
  - python -v
 tags:
  - python

On gitlab, in settings->CI / CD, I have followed the instructions in 'Set up a specific Runner manually'. 在gitlab上,在settings-> CI / CD中,我按照'手动设置特定的Runner'中的说明进行操作。 During the step 'please enter the executor:', I entered 'shell'. 在步骤'请输入执行者:',我输入'shell'。

When I try to commit the above yml file, the runner starts running, although it then gives the following error message: 当我尝试提交上面的yml文件时,运行器开始运行,但它会给出以下错误消息:

Running with gitlab-runner 11.9.2 (fa86510e)
  on wsf-1102 HUx_zvP8
Using Shell executor...
Running on WSF-1102...
DEPRECATION: this GitLab server doesn't support refspecs, gitlab-runner 12.0 will no longer work with this version of GitLab
Fetching changes...
Clean repository
From [my_repo]
   e327c9f..2f0e41f  [my_branch]-> origin/[my_branch]
Checking out 2f0e41f1 as [my_branch]...

Skipping Git submodules setup
$ python -v
'python' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Job failed: exit status 9009

How should I properly write the yml file, so that I can use python as a command to later run a test.py file? 我应该如何正确编写yml文件,以便我可以使用python作为命令以便以后运行test.py文件?

the problem is not in the runner is inside your docker image. 问题不在于跑步者在你的码头图片中。 inside the runner context, you don't have python installed to confirm this first test that python is properly installed in your terminal path. 在运行器上下文中,您没有安装python来确认第一次测试python已正确安装在终端路径中。 then, start with shell executer only for debugging before using and docker image 然后,在使用和docker镜像之前,先使用shell执行器进行调试

try to run this command 尝试运行此命令

gitlab-runner exec shell test

on this simple .gitlab-ci.yml (put the file inside your git repo folder ) 在这个简单的.gitlab-ci.yml上 (把文件放在你的git repo文件夹里

stages:
 - test


test:
 script:
  - python -v

then try to work with the python image when you want to use this image you need to specify you want to run with docker runner after you test the above cases run again on your local machine 然后尝试使用python图像当你想要使用这个图像时,你需要指定你想要在你的本地机器上测试上述情况后运行docker runner

gitlab-runner exec docker test

if you still dosent figure it out try following this guide https://substrakt.com/journal/how-to-debug-gitlab-ci-builds-locally/ 如果您仍然想要了解它,请尝试遵循本指南https://substrakt.com/journal/how-to-debug-gitlab-ci-builds-locally/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM