【问题标题】:Python not recognised as command when using gitlab runner使用 gitlab runner 时 Python 未被识别为命令
【发布时间】:2019-09-06 09:52:09
【问题描述】:

我正在尝试在 gitlab 存储库上设置持续集成。

我添加了以下gitlab-ci.yml 文件:

stages:
 - test


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

在 gitlab 上,在 settings->CI / CD 中,我已按照“手动设置特定 Runner”中的说明进行操作。在'please enter the executor:'这一步中,我输入了'shell'。

当我尝试提交上述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

我应该如何正确编写yml 文件,以便我可以使用python 作为稍后运行test.py 文件的命令?

【问题讨论】:

    标签: python git gitlab gitlab-ci gitlab-ci-runner


    【解决方案1】:

    问题不在于运行器,而在于您的 docker 映像。 在运行器上下文中,您没有安装 python 来确认这一点 首先测试 python 是否正确安装在您的终端路径中。 然后,以shell执行器开始,仅用于调试前使用和docker镜像

    尝试运行这个命令

    gitlab-runner exec shell test
    

    在这个简单的 .gitlab-ci.yml 上(将文件放在你的 git repo 文件夹中

    stages:
     - test
    
    
    test:
     script:
      - python -v
    

    然后尝试使用 python 图像 当您想使用此图像时,您需要在测试上述情况后指定要使用 docker runner 运行 在本地机器上再次运行

    gitlab-runner exec docker test
    

    如果您仍然想不通,请尝试按照本指南进行操作 https://substrakt.com/journal/how-to-debug-gitlab-ci-builds-locally/

    【讨论】:

      猜你喜欢
      • 2019-04-19
      • 1970-01-01
      • 2017-11-26
      • 2012-04-17
      • 2017-12-09
      • 2016-07-21
      • 2011-10-26
      • 2018-12-11
      • 1970-01-01
      相关资源
      最近更新 更多