安装项目运行环境(python依赖包+allure)

目录

前提:
安装git
配置git

一、安装自动化项目依赖包

1.导出项目依赖库

环境:win10

在项目根目录下使用下面的命令

powershell 复制代码
pip freeze > requirements.txt

2.上传到远程仓库

把requirements.txt文件复制到git提交的项目目录下

添加requirements.txt到暂存区

powershell 复制代码
git add requirements.txt

提交到 本地仓库

powershell 复制代码
git commit -m "提交项目依赖包更新"

推送到远程仓库

powershell 复制代码
git push origin master

3.进入jenkins容器内,检查是否安装git

powershell 复制代码
docker exec -it myjenkins bash

查看git版本,检查是否安装git(jenkins容器自带git)

powershell 复制代码
git --version

4.配置git用户信息

配置用户名

powershell 复制代码
git config --global user.name "git_linux"

查看配置后的用户名

powershell 复制代码
git config user.name

配置邮箱

powershell 复制代码
git config --global user.email "git_linux@qq.com"

查看配置后的邮箱

powershell 复制代码
git config user.email

5.生成秘钥

创建SSH Key

powershell 复制代码
ssh-keygen -t rsa -C "git_linux@qq.com"

查看公钥,并复制

powershell 复制代码
cat /root/.ssh/id_rsa.pub

打开gitee,点击头像,点击设置,选择SSH公钥,输入标题,把上面复制的公钥内容粘贴过来,点击确定

6.把代码拉取下来

进入/usr/local目录

powershell 复制代码
cd /usr/local

将gitee上的仓库克隆到本地,仓库地址为SHH地址

powershell 复制代码
git clone 仓库地址


7.安装python项目依赖

进入项目目录,安装项目依赖

powershell 复制代码
pip3 install -r requirements.txt

报错

解决方法:更新setuptools

powershell 复制代码
pip3 install --upgrade setuptools

再次执行安装项目依赖,安装成功

8.运行项目

all.py文件为运行入口

powershell 复制代码
python3 all.py

运行成功,但生成报告的时候少allure插件

二、安装allure

1.jenkins容器内安装allure,进入/usr/local/

powershell 复制代码
cd /usr/local/

2.下载allure

powershell 复制代码
wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.20.1/allure-commandline-2.20.1.tgz

3.解压

powershell 复制代码
tar -xzvf allure-commandline-2.20.1.tgz

4.创建软连接

powershell 复制代码
ln -s /usr/local/allure-2.20.1/bin/allure /usr/bin/allure

5.验证

powershell 复制代码
allure --version

三、安装其他常用工具

1.安装ping

查看ping,显示没有该命令

更新apt-get

powershell 复制代码
apt-get update

安装ping

powershell 复制代码
apt-get install -y inetutils-ping

安装完成

2.安装vim

查看vim

powershell 复制代码
vim

安装vim

powershell 复制代码
apt-get install -y vim

安装成功

四、再次运行项目

1.成功运行并生成报告

到此jenkins容器内项目运行环境已经配置完成,下一步配置jenkins

相关推荐
卷无止境6 分钟前
Python 异常处理:从入门到工程实践
后端·python
garuda herb8 分钟前
生成专题页Blog--建立并返回 MySQL 数据库连接
python·mysql
ONE_SIX_MIX12 分钟前
qwenpaw-plugin-file-tools QwenPaw增强文件工具 更新 v1.1.1
python·qwenpaw
AOwhisky16 分钟前
Python 学习笔记(第五期)——组合数据类型:列表、元组、集合与字典精讲——核心知识点自测与详解
开发语言·笔记·python·学习·云计算
码农学院35 分钟前
GEO与SEO协同:从传统搜索到生成式搜索的平滑迁移路径
服务器·前端·python
程序员羽痕35 分钟前
基于 Django + PyTorch 的中文字体识别系统
pytorch·python·django
java_logo2 小时前
Apache Doris Docker 部署指南:实时分析数据库实战
数据库·docker·apache·doris·apache doris·轩辕镜像·docker部署doris
大模型码小白11 小时前
【Python零基础教程】继承、多态与魔法函数:面向对象编程三大核心特性详解
java·大数据·开发语言·人工智能·python·ai编程
麻雀飞吧11 小时前
最新量化学习路径,交易认知和技术实现要并行
人工智能·python
C^h15 小时前
python函数学习
人工智能·python·机器学习