Mac + python + selenium + jenkins操作步骤和问题集合
-
前言
- 代码已经提交到gitlab上
-
jenkins上操作步骤
- 新建任务
2. 输入任务名称,并选择构建一个自由风格的软件项目
3. 进入配置页面
General内填写描述
源码管理:输入gitlab上的地址,Credentials为访问用户,可以点添加进行新增
gitlab上项目的
无法连接仓库:Command "git ls-remote -h -- git@host:chenjuan0021/po_ui_test_share_cloud_frame.git HEAD" returned status code 128:
stdout:
stderr: remote:
remote: ========================================================================
remote:
remote: The project you were looking for could not be found.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
把git上项目改成Internal即可:
Branches to build选择构建的分支
构建前先清除workspace
构建命令
因为mac电脑默认是python2.7,如果项目需要用到python3以上版本,执行的时候,要写上python3路径
可以通过在代码中增加以下代码来判断当前运行的python版本
import sys
print(sys.path)
构建后操作,可输出报告
-
点击立即构建出现的问题一
运行时自定义的包找不到,解决方法一:jenkins中添加环境变量
解决方法二: run_all_cases.py 运行入口代码中添加
import os
import sys
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
-
点击立即构建出现的问题二
找不到第三方的包,有可能是jenkins服务器未安装第三方包,还有可能是pyhton运行的版本不对