Issue
I have a robot command like python -m robot --include staging_lp_items
which is run perfectly in my system.
When trying to run this with GitLab runner (as a stage script) in a server machine, this error is shown:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/site-packages/robot/__main__.py", line 25, in <module>
from robot import run_cli
ImportError: cannot import name 'run_cli' from 'robot' (/usr/local/lib/python3.9/site-packages/robot/__init__.py)
I also to make sure of installing robot, return the pip list
before main script and robot
is installed on the server environment as well as other requirements in requirements.txt
file.
Here is the system config:
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
GitLab Yaml:
stages:
- build
- build_branch
- test
variables:
REGISTRY_IMAGE: ${CI_REGISTRY}/qa/${CI_PROJECT_NAME}
GIT_IMAGE: ${CI_REGISTRY}/qa/${CI_PROJECT_NAME}
build:
image: docker:latest
stage: build
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- echo image name $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
- docker build -t $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
- docker push $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
rules:
- when: manual
build_branch:
image: docker:latest
stage: build_branch
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- echo project image is ${GIT_IMAGE}
- docker build --build-arg CI_COMMIT_REF_NAME=master -t $GIT_IMAGE:$CI_COMMIT_REF_NAME .
- docker push $GIT_IMAGE:$CI_COMMIT_REF_NAME
rules:
- when: manual
allow_failure: true
run_test:
image: $GIT_IMAGE:$CI_COMMIT_REF_NAME
stage: test
script:
- cat /etc/os-release
- chmod +x ./.deploy/run-test.sh
- ./.deploy/run-test.sh
rules:
- when: manual
allow_failure: false
There are 3 stages, build
and build_branch
work fine. The last one is the main stage that I have a problem with it. This stage will run (eval) the run-test.sh
that has a simple python-robotframework command I mentioned before.
Python Version : 3.9
Dockerfile
FROM python:3.9
ARG CI_COMMIT_REF_NAME=master
COPY . .
RUN pip install [Repository]
RUN pip install -r requirements.txt
Solution
Your requirementst.txt is invalid. You have robot
there https://pypi.org/project/robot/, while the library that you want to use is named robotframework
https://pypi.org/project/robotframework/.
Rename robot
to robotframework
in your requirements.txt.
Answered By - KamilCuk Answer Checked By - Robin (WPSolving Admin)