我在Google Compute Engine中设置了Jenkins实例,以便在this page from Google之后构建和部署App Engine Java项目。
我已将Jenkins配置为仅在Maven构建成功时运行以下shell命令:gcloud --project=decent-ellipse-843 preview app deploy target/*-SNAPSHOT/
当我尝试构建时,部署失败并显示以下跟踪:
+ gcloud --project=decent-ellipse-843 preview app deploy target/backend-api-0.0.1-SNAPSHOT/
Traceback (most recent call last):
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 183, in <module>
main()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 179, in main
_cli.Execute()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 488, in Execute
post_run_hooks=self.__post_run_hooks)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 1016, in Run
result = command_instance.Run(args)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/exceptions.py", line 86, in TryFunc
return func(*args, **kwargs)
File "/usr/local/share/google/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 158, in Run
stage_dir = self.__MakeStagingDir(project, args, deployable)
File "/usr/local/share/google/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 268, in __MakeStagingDir
java_app_update = appcfg_java.JavaAppUpdate(deployable, args)
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appcfg_java.py", line 146, in __init__
self.app_engine_web_xml = self._ReadAppEngineWebXml()
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appcfg_java.py", line 205, in _ReadAppEngineWebXml
parser=app_engine_web_xml_parser.AppEngineWebXmlParser)
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appcfg_java.py", line 217, in _ReadAndParseXml
return parser().ProcessXml(file_handle.read())
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/app_engine_web_xml_parser.py", line 71, in ProcessXml
xml_root = ElementTree.fromstring(xml_str)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML
parser = XMLParser(target=TreeBuilder())
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1466, in __init__
"No module named expat; use SimpleXMLTreeBuilder instead"
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Maven构建成功,我可以通过手动发出gcloud命令来部署项目。
即使我从同一目录和同一用户(gcloud
)下运行完全相同的tomcat
命令,部署也会成功而没有错误。
我重新安装了python并更新了Google Cloud SDK而没有任何结果。
该实例运行的是Python 2.7.3,Jenkins 1.598,JDK 7u76和Maven 3.2.2。
我希望有人可以帮我解决这个问题!
答案 0 :(得分:0)
我遇到了类似的问题,在cloud-dev-python slave上运行我的工作。这些图像缺少您可能需要的构建工具,以便正确构建和部署。我的解决方案是连接到docker镜像并第一次手动安装工具。
# on docker host, connect to java image
CONTAINER_ID=$(docker ps | grep cloud-dev-java | awk '{print $1}');
docker exec -i -t $CONTAINER_ID bash
# on docker image, install crap to build lxml, etc
gcloud -q components update preview app && apt-get update \
&& apt-get install -y build-essential libz-dev libxml2-dev \
libxslt1-dev python-dev python-pip && apt-get autoremove
给它一个旋转,看看它是否有帮助。即使设置正确,我目前仍然坚持使用服务帐户进行身份验证...