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

相关推荐
ocean21032 小时前
2025-2026年Python面试高频知识点洞察
开发语言·python·面试·python八股文
Warson_L2 小时前
Python的OrderedDict
python
隐擎fox2 小时前
高性能网络爬虫架构设计:基于 Python 的长连接复用与分布式会话池调度实践
分布式·python·网络协议·tcp/ip·高并发·网络爬虫、
Warson_L2 小时前
Python的TypedDict
python·langchain·llm
晓窗科技3 小时前
口碑好的AI基座服务商
大数据·人工智能·python
小灰灰搞电子4 小时前
Python 信号量详解:并发控制实战
python·信号量
新时代牛马4 小时前
cyclictest 毛刺从哪来?从ftrace、latencytop、perf到IRQ/调度延迟定位
android·开发语言·python·kotlin
Dxy12393102164 小时前
Python如何结合AI解决数据分析问题
人工智能·python·数据分析
cpolar技术支持4 小时前
Docker 容器启动失败怎么查?端口、日志、权限与网络排障完整教程
linux·docker·容器·cpolar·网络排障
IvanCodes4 小时前
Python 基础语法(七):推导式与常见遍历写法
开发语言·python