Gitlab-runner 运行 python2 而不是 python 3

问题描述

这是我的 gitlab-ci.yml 文件

image: python:3.6

before_script:
  - python --version
  - pip install -r requirements.txt

stages:
  - test

test:
  stage: test
  script:
    - chmod +x ./scripts/lint.sh
    - ./scripts/lint.sh
    - chmod +x ./scripts/tests.sh
    - ./scripts/tests.sh

请注意,在我的本地机器上,作业运行没有任何问题,并且使用的是 python 3.6.13

在线运行作业测试,我得到这个错误:它没有任何意义!

以下是可以运行未标记作业的运行器的配置和错误消息。

enter image description here

enter image description here

解决方法

您显示的屏幕截图,作业是使用 shell-executor 运行的,因此在您安装了 gitlab-runner 的任何机器上使用 Python 版本。

看起来您想使用 docker-executor 来使用 image: python:3.6,因此我将重新安装运行程序以使用 docker executor

或者,您可以更新使用 shell 执行程序的机器,以使用 Python 3。

另一个问题可能是您没有标记跑步者,并且使用了错误的 gitlab-runner。确保您已标记您的 shell / docker runners,即使用 shell-runnerdocker-runner,然后在 test 作业中,添加:

tags:
  - docker-runner

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...