Open Cetlan opened 2 years ago
I also see this problem. It appears the PYTHON_PATH
envvar gets set, but the correct paths do not get prepended to PATH
Any update on this topic? Is there a workaround to make it work?
I'm having issues with Docker. I assume that the reason might be the same. I'm using
docker.image('imagename:latest').inside('''-m=30G ...'') {
sh '''python3 -m venv conan_venv'''
//withPythonEnv('conan_venv/') {
withPythonEnv(WORKSPACE+'/conan_venv/') {
...
}
}
Do I understand correctly that Pyenv Pipeline Plugin currently doesn't support Docker Pipeline plugin? Or am I doing something wrong?
Indeed it seems that the plugin does not work with Docker :(
node('linux') {
docker.image('python:3.8-slim-bullseye').inside {
sh "echo python"
withPythonEnv('python') {
sh("""
which python
which python3
""")
}
}
}
16:26:22 [Pipeline] withDockerContainer
16:26:22 ubuntu-agent-18-1 does not seem to be running inside a container
16:26:22 $ docker run -t -d -u 1000:1000 -w /home/jenkins/workspace/sandbox/tmp-python -v /home/jenkins/workspace/sandbox/tmp-python:/home/jenkins/workspace/sandbox/tmp-python:rw,z -v /home/jenkins/workspace/sandbox/tmp-python@tmp:/home/jenkins/workspace/sandbox/tmp-python@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** python:3.8-slim-bullseye cat
16:26:30 $ docker top e03c995ba0389789a334303d8f5d0b86213d3f938edcdbc916482b8ba1c13649 -eo pid,comm
16:26:30 [Pipeline] {
16:26:30 [Pipeline] sh
16:26:30 + echo python
16:26:30 python
16:26:30 [Pipeline] withPythonEnv
16:26:30 $ docker exec e03c995ba0389789a334303d8f5d0b86213d3f938edcdbc916482b8ba1c13649 python --version
16:26:30 $ docker exec e03c995ba0389789a334303d8f5d0b86213d3f938edcdbc916482b8ba1c13649 python -m venv /home/jenkins/workspace/sandbox/tmp-python/.pyenv-python
16:26:36 [Pipeline] {
16:26:36 [Pipeline] sh
16:26:37 + which python
16:26:37 /usr/local/bin/python
16:26:37 + which python3
16:26:37 /usr/local/bin/python3
16:26:37 [Pipeline] }
16:26:37 [Pipeline] // withPythonEnv
16:26:37 [Pipeline] }
16:26:37 $ docker stop --time=1 e03c995ba0389789a334303d8f5d0b86213d3f938edcdbc916482b8ba1c13649
16:26:40 $ docker rm -f e03c995ba0389789a334303d8f5d0b86213d3f938edcdbc916482b8ba1c13649
16:26:40 [Pipeline] // withDockerContainer
It successfully creates the venv directory, but fails to use it in sh
steps.
The workaround that works for us:
environment { PATH = "$WORKSPACE/.pyenv-python3/bin:$PATH" }
and in the stage:
python3.11 -m venv $WORKSPACE/.pyenv-python3
Version report
Jenkins and plugins versions report:
Reproduction steps
Create a new pipeline job using
Results
Expected result:
Expected the commands inside the
withPythonEnv
block to print the executable and build flags for the virtual environment.Actual result:
Given what I know about this plugin, I suppose this could be a kubernetes pipeline problem instead, with environment variables not getting passed through properly. And since this plugin hasn't been updated in a couple years, maybe this is no longer maintained? If that's the case, there is an obvious workaround of just not using this plugin, and explicitly handling the virtual environment myself in the
sh
commands. But thought I'd check if maybe this is a fixable bug, or if there's a known/official workaround.(and yes, I'm aware that in theory there's no need for the virtualenv inside a container, because the container is isolated, but due to certain combinations of dependencies, scripts, etc, it's not feasible right now to try to set up a build without the virtualenv)