I am new in devops and trying to pytest with Gitlab CI/CD and local docker runner. My job failed with this error:
WARNING: Failed to pull image with policy "if-not-present": invalid reference format (manager.go:237:0s)
ERROR: Job failed: failed to pull image "python 3.9" with specified policies [if-not-present]: invalid reference format (manager.go:237:0s)
How can i fix it?
My .gitlab-ci.yml
stages:
- test
image: python 3.9
run_tests:
stage: test
before_script:
- pip install -r requirements.txt
script:
- pytest -v -s
tags:
- docker-local
My local runner.yml
services:
runner:
container_name: gitlab-runner
image: gitlab/gitlab-runner:latest
volumes:
- ./runner/:/etc/gitlab-runner
- /var/run/docker.sock:/var/run/docker.sock
restart: always
config.toml
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "test_runner_local"
url = "https://my_url"
id = 8
token = "TOKEN"
token_obtained_at = data
token_expires_at = data
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
pull_policy = ["if-not-present"]
tls_verify = false
image = "python:3.9"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
If I delete the pull_policy field in config.toml or replace the value with 'always' - the error does not go away.
You miss the colon, try this:
stages:
- test
image: python:3.9 # you miss ":"
run_tests:
stage: test
before_script:
- pip install -r requirements.txt
script:
- pytest -v -s
tags:
- docker-local
Besides, there is free quota for CI/CD on gitlab.com . You can test whether your job works fine online, then test it at local, may save you a little debug time.