Jenkins搭建完成之后,我们可以把已经写好的Python代码部署到Jenkins平台上执行。执行的时候都在服务器上运行的。所以服务器上需要安装 git python。

安装git

默认Linux上没有git 环境。

  1. yum install -y git

image.png

安装配置Python

python在Linux平台上需要进行源码安装。

下载Python Linux 源码

官网:https://www.python.org/downloads/source/
image.png

下载完成之后,将源码上传至服务器。

解压文件

  1. tar -xf Python-3.10.2.tgz

配置python

  1. cd Python-3.10.2/
  2. ./configure

image.png

安装python

配置完成之后对python进行安装

  1. make && make install

对python的源码进行自动的编译安装。
image.png

检查Python版本

因为在Linux平台默认安装有的 python2.7 的版本,不能卸载。安装的Python3版本。使用的时候需要使用命令 python3

  1. python3 --version

image.png

安装pytest,requests

等下在服务器上运行我们写好的Python代码,但是我们写的代码中有使用到pytest,requests,

  1. pip3 install pytest
  1. pip3 install requests