我通过anaconda在EC2 Ubuntu实例上安装了python。
python返回的命令*/home/ubuntu/anaconda3/bin/python*
Jenkins安装在*/var/lib/jenkins*
中
我正在尝试运行一个简单的";Hello World"保存在名为*test.py*
的文件中并位于*/home/ubuntu/scripts/*
文件夹中的脚本。
当*python /home/ubuntu/scripts/test.py*
在终端上运行时;执行shell";詹金斯。
为什么以及如何配置Jenkins来逐步运行python脚本?
问题是anaconda-python安装仅对用户可用"ubuntu";。为了让Jenkins能够运行python脚本;詹金斯;用户需要使用该安装。
为了解决这个问题,我就是这么做的:
- 以jenkins身份使用命令
sudo su -s /bin/bash jenkins
登录 - 将python安装位置编辑为
export PATH=/home/ubuntu/anaconda3/bin:$PATH
- 通过
which python
检查路径是否正确 - 以ubuntu用户身份重新登录
- 通过
sudo service jenkins restart
重新启动Jenkins(不确定是否需要(
现在我可以通过Jenkins运行python脚本了。