本文介绍了詹金斯:把我的Python模块放在PYTHONPATH上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jenkins来测试一个Python模块我发展。但是,我收到如下错误:

I am using Jenkins to test a Python module nodepy that I develop. However, I get errors like the following:

File "/var/lib/jenkins/jobs/NodePy/workspace/convergence.py", line 6, in workspace.convergence
Failed example:
    from nodepy import rk, convergence, ivp
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest workspace.convergence[0]>", line 1, in <module>
        from nodepy import rk, convergence, ivp
    ImportError: No module named nodepy

如何在Jenkins中设置PYTHONPATH(以便我的模块可导入)?

How do I set the PYTHONPATH in Jenkins (so that my module is importable)?

我甚至不知道我应该添加哪个目录。看来Jenkins把东西放在jenkins / jobs / nodepy / workspace /中,所以目录甚至没有python找到它的正确名称。

I'm not even sure which directory I should add. It seems that Jenkins puts things in jenkins/jobs/nodepy/workspace/, so the directory doesn't even have the right name for python to find it.

编辑:

python模块是一个 git 存储库,我配置了我的jenkins工作来观看和结帐。

The python module nodepy is a git repository that I have configured my jenkins job to watch and checkout.

推荐答案

事实证明,我需要做的只是按照为了让詹金斯克隆我的这个问题,如何获得哈德森 - git-plugin-to-clone-repo-with-the-repo-in-the-pa repo进入子目录 workspace / nodepy / 。由于Jenkins在工作区中运行构建,它会找到该包。

It turns out all I needed to do was follow the answer to this question in order to have Jenkins clone my repo into a subdirectory workspace/nodepy/. Since Jenkins runs the build in workspace, it then finds the package.

当我第一次这样做时,它以某种方式创建了nodepy / nodepy / nodepy / ...目录的无限递归。在我清理工作区后,这个问题就消失了。

When I first did this, it somehow created an infinite recursion of nodepy/nodepy/nodepy/... directories. After I cleared out the workspace, this problem went away.

这篇关于詹金斯:把我的Python模块放在PYTHONPATH上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!