title: How to set the PYTHONPATH in Jenkins on docker
body: <p>I'm new to Jenkins so I'm following this tutorial: <a href="https://www.jenkins.io/doc/tutorials/build-a-python-app-with-pyinstaller/#setup-wizard" rel="nofollow noreferrer">https://www.jenkins.io/doc/tutorials/build-a-python-app-with-pyinstaller/#setup-wizard</a></p>
  
  <p>When I built the project the Build and the Test stages encountered no problem, but on the Deliver stage an error occurred. </p>
  
  <p>This is the log:</p>
  
  <pre><code>+ pwd   
  + docker run -v /var/jenkins_home/jobs/python/workspace/8/sources:/src cdrx/pyinstaller-linux:python3 'pyinstaller -F add2vals.py'
  bash: cannot set terminal process group (-1): Inappropriate ioctl for device
  bash: no job control in this shell
  pyinstaller -F add2vals.py
  131 INFO: PyInstaller: 3.6
  132 INFO: Python: 3.7.5
  134 INFO: Platform: Linux-4.19.76-linuxkit-x86_64-with-debian-wheezy-sid
  135 INFO: wrote /src/add2vals.spec
  140 INFO: UPX is available.
  Traceback (most recent call last):
    File "/root/.pyenv/versions/3.7.5/bin/pyinstaller", line 8, in &lt;module&gt;
      sys.exit(run())
  
    File "/root/.pyenv/versions/3.7.5/lib/python3.7/site-packages/PyInstaller/__main__.py", line 114, in run
  
      run_build(pyi_config, spec_file, **vars(args))
  
    File "/root/.pyenv/versions/3.7.5/lib/python3.7/site-packages/PyInstaller/__main__.py", line 65, in run_build
  
      PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  
    File "/root/.pyenv/versions/3.7.5/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 734, in main
  
      build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  
    File "/root/.pyenv/versions/3.7.5/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 681, in build
  
      exec(code, spec_namespace)
  
    File "/src/add2vals.spec", line 17, in &lt;module&gt;
  
      noarchive=False)
  
    File "/root/.pyenv/versions/3.7.5/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 191, in __init__
  
      raise ValueError("script '%s' not found" % script)
  
  ValueError: script '/src/add2vals.py' not found
  
  script returned exit code 1
  </code></pre>
  
  <p>I compared it to the log from the tutorial and besides the python version, another difference is this:</p>
  
  <p><a href="https://i.stack.imgur.com/SYHhB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SYHhB.png" alt="snippet of log from tutorial"></a></p>
  
  <p>In the Jenkin's configuration system I already added a global variable for PYTHONPATH.
  <a href="https://i.stack.imgur.com/en7mz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/en7mz.png" alt="enter image description here"></a></p>
  
  <p>Is there some set-up that I seem to be missing?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I changed the image containing the log into the actual log, my mistake.
  Also I did not use a Dockerfile, I followed the instructions on the tutorial where it used Jenkinsfile where it downloads images per stage as indicated.</p>
  
  <p>I did not include the steps on the Build and Test stage since there is no problem in their execution.</p>
  
  <pre><code>stage('Build') {
      agent {
          docker {
              image 'python:3.7.5'
          }
      }
  }
  stage('Test') {
          agent {
              docker {
                  image 'qnib/pytest'
              }
          }
  }
  stage('Deliver') {
              agent any
              environment {
                  VOLUME = '$(pwd)/sources:/src'
                  IMAGE = 'cdrx/pyinstaller-linux:python2'
              }
              steps {
                  dir(path: env.BUILD_ID) {
                      unstash(name: 'compiled-results')
                      sh "docker run --rm -v ${VOLUME} ${IMAGE} 'pyinstaller -F add2vals.py'"
                  }
              }
              post {
                  success {
                      archiveArtifacts "${env.BUILD_ID}/sources/dist/add2vals"
                      sh "docker run --rm -v ${VOLUME} ${IMAGE} 'rm -rf build dist'"
                  }
              }
          }
  </code></pre>