zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Jenkins部署python-flask后端项目,持续集成(jinkins配置python虚拟环境)

2023-09-14 09:00:31 时间

第一步:新建项目
Jenkins -> 新建任务 -> 起名字,构建一个自由风格的软件项目 -> 保存

第二步,添加git仓库

第三步,构建,添加shell

cd /root/.virtualenvs  #cd到虚拟环境所在目录,automationVenv是虚拟环境目录名称
. automationVenv/bin/activate  #激活虚拟环境
cd /home/wangju/gitProject/automationtest#cd 到python项目所在目录
python3 main.py#执行python脚本

实际我的,

cd /home/crs-dev/.virtualenvs
pwd
. qzautotest/bin/activate
which python
PIDS=`ps -ef | grep gunicorn |grep -v grep | awk '{print $2}' | head -1`
if [ "$PIDS" != "" ]; then
kill -9 $PIDS
fi
cd /root/.jenkins/workspace/FlaskServer
BUILD_ID=
gunicorn manager:app -c gunicorn.conf.py -D
exit