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

相关推荐
Li emily9 分钟前
解决港股实时行情数据 API 接入难题
人工智能·python·fastapi
wfeqhfxz258878227 分钟前
农田杂草检测与识别系统基于YOLO11实现六种杂草自动识别_1
python
mftang1 小时前
Python 字符串拼接成字节详解
开发语言·python
0思必得01 小时前
[Web自动化] Selenium设置相关执行文件路径
前端·爬虫·python·selenium·自动化
石去皿1 小时前
大模型面试通关指南:28道高频考题深度解析与实战要点
人工智能·python·面试·职场和发展
曦云沐1 小时前
【避坑指南】Ubuntu更新报错“Repository is not signed”的快速修复
linux·ubuntu·docker
jasligea1 小时前
构建个人智能助手
开发语言·python·自然语言处理
测试秃头怪1 小时前
面试大厂就靠这份软件测试八股文了【含答案】
自动化测试·软件测试·python·功能测试·面试·职场和发展·单元测试
测试杂货铺1 小时前
软件测试面试题大全,你要的都在这。。
自动化测试·软件测试·python·功能测试·面试·职场和发展·测试用例
测试大圣2 小时前
软件测试基础知识总结(超全的)
软件测试·python·功能测试·测试工具·职场和发展·单元测试·测试用例