问题
I get the following error when I try to execute a build on the Google provisioned Jenkins servers in Compute Engine.
[deployment_5371449468518400_1411607125060] $ /bin/sh -xe /tmp/hudson807438832151987098.sh
+ nosetests --with-xunit --xunit-file=nosetests.xml
E
======================================================================
ERROR: Failure: ImportError (No module named google.appengine.ext)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 414, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/var/jenkins/workspace/deployment_5371449468518400_1411607125060/tests.py", line 9, in <module>
from google.appengine.ext import ndb
ImportError: No module named google.appengine.ext
----------------------------------------------------------------------
Ran 1 test in 0.448s
I am confident that this is happening because of the following line in my tests.py
from google.appengine.ext import ndb
Please help.
I am including a link to a doc which has more details
回答1:
Joseph, as the path is not set correctly, please add this to the beginning of your tests.py file:
import sys
sys.path.append("/google-cloud-sdk/platform/google_appengine")
Please, don't forget to add this part before trying to import anything from that library as the path wouldn't be configured yet.
In other words:
import sys
sys.path.append("/google-cloud-sdk/platform/google_appengine")
some other imports
#next import ONLY after the path has been updated to point to the App Engine libraries
from google.appengine.ext import ndb
来源:https://stackoverflow.com/questions/26029120/google-push-to-deploy-pipelines-unit-tests-fail-with-module-import-error