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

相关推荐
2301_7693406717 分钟前
如何在 Vuetify 中可靠捕获 Chip 关闭事件(包括键盘触发).txt
jvm·数据库·python
南 阳2 小时前
Python从入门到精通day66
开发语言·python
m0_596749092 小时前
JavaScript中手动实现一个new操作符的底层逻辑
jvm·数据库·python
DTAS尺寸公差分析软件2 小时前
DTAS3D v13.0 三维尺寸公差分析软件可申请试用
python·尺寸公差分析·三维公差分析·公差仿真软件·尺寸链计算
DTAS尺寸公差分析软件2 小时前
DTAS 3D公差分析软件最新版本介绍
python·3d·尺寸公差分析·尺寸链计算·尺寸工程·尺寸链校核软件·公差仿真分析
PieroPc3 小时前
CAMWATCH — 局域网摄像头监控系统 Fastapi + html
前端·python·html·fastapi·监控
feasibility.3 小时前
反爬十层妖塔:现代爬虫攻防的立体战争
爬虫·python·科技·scrapy·rust·go·硬件
十八旬3 小时前
快速安装ClaudeCode完整指南
开发语言·windows·python·claude
dFObBIMmai3 小时前
如何在 CSS 中实现元素的绝对定位,使其不受窗口尺寸变化影响
jvm·数据库·python
WL_Aurora4 小时前
Python 算法基础篇之集合
python·算法