安装项目运行环境(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

相关推荐
明月_清风1 小时前
从“能用”到“专业”:构建生产级装饰器与三层逻辑拆解
后端·python
曲幽11 小时前
数据库实战:FastAPI + SQLAlchemy 2.0 + Alembic 从零搭建,踩坑实录
python·fastapi·web·sqlalchemy·db·asyncio·alembic
用户83562907805115 小时前
Python 实现 PowerPoint 形状动画设置
后端·python
ponponon17 小时前
时代的眼泪,nameko 和 eventlet 停止维护后的项目自救,升级和替代之路
python
Flittly17 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(5)Skills (技能加载)
python·agent
敏编程17 小时前
一天一个Python库:pyarrow - 大规模数据处理的利器
python
Flittly19 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(4)Subagents (子智能体)
python·agent
明月_清风1 天前
Python 装饰器前传:如果不懂“闭包”,你只是在复刻代码
后端·python
明月_清风1 天前
打破“死亡环联”:深挖 Python 分代回收与垃圾回收(GC)机制
后端·python
ZhengEnCi2 天前
08c. 检索算法与策略-混合检索
后端·python·算法