django - Django和Jenkins在执行shell上出现多个错误
问题描述
我正在尝试为 python-django 应用程序实现持续集成。我在 vps 上安装了 Jenkins,并创建了一个提取我的 bitbucket 代码的作业。
现在我正在尝试从测试目录执行测试,但是在詹金斯的执行外壳中出现了一些问题。
这是 shell 控制台输出:
7 - Link the cms_core app in the project using a symbolic link
/var/lib/jenkins/workspace/ed1cms/test_cms_core
total 16
drwxr-xr-x 3 jenkins jenkins 4096 Jul 5 16:12 .
drwxr-xr-x 5 jenkins jenkins 4096 Jul 5 16:12 ..
lrwxrwxrwx 1 jenkins jenkins 16 Jul 5 16:12 cms_core -> ../core/cms_core
-rwxr-xr-x 1 jenkins jenkins 811 Jul 5 16:12 manage.py
drwxr-xr-x 2 jenkins jenkins 4096 Jul 5 16:12 test_cms_core
/tmp/jenkins7283490794872735254.sh: line 28: prinf: command not found
Collecting cms_core
Could not find a version that satisfies the requirement cms_core (from versions: )
No matching distribution found for cms_core
8 - Finally, we can run the tests through django-jenkins
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/var/lib/jenkins/.virtualenvs/tmp-8ca50c09c788e0c/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/var/lib/jenkins/.virtualenvs/tmp-8ca50c09c788e0c/lib/python3.6/site-packages/django/core/management/__init__.py", line 307, in execute
settings.INSTALLED_APPS
File "/var/lib/jenkins/.virtualenvs/tmp-8ca50c09c788e0c/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/var/lib/jenkins/.virtualenvs/tmp-8ca50c09c788e0c/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/var/lib/jenkins/.virtualenvs/tmp-8ca50c09c788e0c/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/var/lib/jenkins/.virtualenvs/tmp-8ca50c09c788e0c/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'cms_core'
9 - Deactivate virtualenv so it is destroyed
Removing temporary environment: tmp-8ca50c09c788e0c
Removing tmp-8ca50c09c788e0c...
Finished: SUCCESS
7,8,9 是我在 shell 中用 printf 编写的步骤,所以我可以一步一步地跟踪正在发生的事情。在第 7 步之前没有发生错误。
这是我的执行shell脚本:
#!/bin/bash
printf "\n\n1 - Set-up some things so we can use virtualenvwrapper\n\n"
source ~/.bash_profile
printf "\n\n2 - Create a temporary virtual environment for Python\n\n"
mktmpenv -p /opt/python-versions/3.6.3/bin/python3
printf "\n\n3 - We need to go back to the path we initially were, not in the virtual env path\n\n"
cd -
printf "\n\n4 - Install requirements to be able to create a Django project and run tests\n\n"
pip install -r cms_core/tests/requirements.txt
printf "\n\n5 - Create the Django project\n\n"
rm -rf test_cms_core
django-admin startproject test_cms_core
printf "\n\n6 - Go in the project folder\n\n"
cd test_cms_core
printf "\n\n7 - Link the cms_core app in the project using a symbolic link\n\n"
ln -s ../core/cms_core .
pwd
ls -la
printf "\n\n8 - Finally, we can run the tests through django-jenkins\n\n"
./manage.py jenkins --settings=cms_core.tests.settings
printf "\n\n9 - Deactivate virtualenv so it is destroyed\n\n"
deactivate
解决方案
- 您的代码中似乎有错字。只需搜索“prinf”,可能缺少t 。
- 您的模块 cms_core 未安装或找不到。也许您只是在错误的文件夹中使用您的 django 设置?或者,如果所有要求都安装正确,请使用 pip list 检查您的 virtualenv。
推荐阅读
- java - Spring 存储库将 HQL 发送到数据库服务器
- java - 如何转换 ArrayList
到包含十进制值的双[]? - javascript - 查看每个调用旁边的 javascript 代码的执行时间
- azure - Azure CDN 终结点中的裸域具有错误的 HTTPS 证书名称
- php - 根据另一个输入值(0-100 之间的数字)将 DIV ID(字母)传递/回显到输入值
- python - 在没有scipy的python中将COO转换为CSR格式
- php - HTML 显示为文本
- python - 如何从列表中获取方括号中的唯一值
- html - 可以
在没有父级的情况下使用 - c#-4.0 - 一种使用 SOLID 原理替换 Switch 的方法