简体   繁体   English

从Bamboo运行Python脚本

[英]Run a python script from bamboo

I'm trying to run a python script from bamboo. 我正在尝试从Bamboo运行python脚本。 I created a script task and wrote inline " python myFile.py ". 我创建了一个脚本任务,并内联了“ python myFile.py ”。 Should I be listing the full path for python? 我应该列出python的完整路径吗?

I changed the working directory to the location of myFile.py so that is not a problem. 我将工作目录更改为myFile.py的位置,所以这不是问题。 Is there anything else I need to do within the configuration plan to properly run this script? 为了正确运行此脚本,我还需要在配置计划中做其他事情吗? It isn't running but I know it should be running because the script works fine from terminal on my local machine. 它没有运行,但是我知道它应该正在运行,因为该脚本可以从本地计算机上的终端正常运行。 Thanks 谢谢

I run a lot of python tasks from bamboo, so it is possible. 我从竹子运行了很多python任务,所以有可能。 Using the Script task is generally painless... 使用脚本任务通常很容易...

You should be able to use your script task to run the commands directly and have stdout written to the logs. 您应该能够使用脚本任务直接运行命令,并将stdout写入日志。 Since this is true, you can run: 由于这是真的,因此您可以运行:

'which python' -- Output the path of which python that is being ran. '哪个蟒蛇'-输出正在运行的哪个蟒蛇的路径。

'pip list' -- Output a list of which modules are installed with pip. 'pip list'-输出使用pip安装了哪些模块的列表。

You should verify that the output from the above commands matches the output when ran from the server. 从服务器运行时,应验证上述命令的输出与输出匹配。 I'm guessing they won't match up and once that is addressed, everything will work fine. 我猜他们不会匹配,一旦解决,一切都会很好。

If not, comment back and we can look at a few other things. 如果没有,请发表评论,我们可以看看其他一些内容。

For the future, there are a handful of different ways you can package things with python which could assist with this problem (eg automatically installing missing modules, etc). 将来,您可以通过几种不同的方式使用python打包东西,这可能有助于解决此问题(例如,自动安装缺少的模块等)。

You can also use the Script Task directly with an inline Python script to run your myFile.py: 您还可以将脚本任务直接与内联Python脚本一起使用来运行myFile.py:

/usr/bin/python <<EOF
print "Hello, World!"
EOF

Check this page for a more complex example: https://www.langhornweb.com/display/BAT/Run+Python+script+as+a+Bamboo+task?desktop=true&macroName=seo-metadata 检查此页面以获取更复杂的示例: https : //www.langhornweb.com/display/BAT/Run+Python+script+as+a+Bamboo+task?desktop=true&macroName=seo-metadata

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM