LearnToGrow
LearnToGrow

Reputation: 1750

Gitlab-runner run python2 instead of python 3

here is my gitlab-ci.yml file:

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

Note that on my local machine, the job is running without any problem and it is using python 3.6.13

Running the job test online, I got this error: It does not make any sense!

below is the config of the runner which can run untagged job and the error message.

enter image description here

enter image description here

Upvotes: 1

Views: 2280

Answers (1)

Rekovni
Rekovni

Reputation: 7364

The screenshot you've showed, the job is run using the shell-executor, and so is using the Python version on whichever machine you have installed the gitlab-runner on.

It looks like you want to use the docker-executor for using image: python:3.6, and so I would reinstall the runner to use the docker executor.

Alternatively, you can update your machine which is using the shell executor, to have Python 3 instead.

Another issue could be that you have not tagged your runners, and are using the wrong gitlab-runner. Make sure you've tagged your shell / docker runners, ie with shell-runner or docker-runner, and then in the test job, add:

tags:
  - docker-runner

Upvotes: 2

Related Questions