部署过程出现的问题记录
代码同步
本地管理
- VSCode
Gitlab管理
- 类似GitHub
CentOS服务器配置
Chrome浏览器安装
$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
$ sudo yum localinstall google-chrome-stable_current_x86_64.rpm
$ rpm -qa |grep chrome
Chromedriver下载
$ wget http://chromedriver.storage.googleapis.com/89.0.4389.23/chromedriver_linux64.zip
$ sudo mv chromedriver_linux64.zip /usr/local/bin/
$ unzip /usr/local/bin/chromedriver_linux64.zip
Jenkins创建任务
源码管理
- Git
- Repository URL: git@gitlab.yourdomainname.com:yourname/reponame.git
- Credentials: jenkins
- Branches to build: */main
构建触发器
- 定时构建:H/5 * * * *
构建步骤
- Execute shell
python3 checker.py
问题与解决
CentOS 7.8 build Python3.9.4失败
- 考虑yum问题,参考:
https://wiki.centos.org/yum-errors - 如果还是失败,尝试如下命令
$ sudo yum-builddep python
如果仍然失败,报错:https://rpm.nodesource.com/pub_14.x/el/7/SRPMS/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found - 如果依然失败,参考
https://github.com/nodesource/distributions/issues/553
$ sudo yum remove nodejs nodesource-release
$ sudo yum clean all
$ curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash -E -
$ sudo yum install nodejs
- 上述步骤未验证,为了避免公共服务器未知影响,直接通过yum安装Python36
$ sudo yum install epel-release
$ sudo yum install python36
Jenkins下载代码报错
错误信息:ERROR: Couldn’t find any revision to build. Verify the repository and branch configuration for this job.
- 检查任务配置->源码管理->指定分支
默认为:
*/master
修改为:
*/main
webdriver权限错误
错误信息:PermissionError: [Errno 13] Permission denied: ‘./wd/chromedriver’
- 代码目录webdriver没有系统权限,改用系统webdriver, e.g. /usr/local/bin/chromedriver
browser = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', options=options)