我如何触发一个";行为举止;从Jenkins执行Shell构建步骤进行测试?
我有一系列使用selenium独立服务器运行的BDD selenium测试。要运行它们,我在终端中输入以下代码(一旦我进入正确的目录): 测试完成后:我如何触发一个";行为举止;从Jenkins执行Shell构建步骤进行测试?,shell,selenium,jenkins,Shell,Selenium,Jenkins,我有一系列使用selenium独立服务器运行的BDD selenium测试。要运行它们,我在终端中输入以下代码(一旦我进入正确的目录): 测试完成后: deactivate # Ends the virtualenv 我已经配置了一个Jenkins项目,该项目使用相同的文件和测试访问GitHub repo。在项目中,有一个执行shell命令的构建步骤。那里的代码是: #!/bin/bash cd dev #Enter right directory
deactivate # Ends the virtualenv
我已经配置了一个Jenkins项目,该项目使用相同的文件和测试访问GitHub repo。在项目中,有一个执行shell命令的构建步骤。那里的代码是:
#!/bin/bash
cd dev #Enter right directory
source project/bin/activate #Activate virtualenv
behave
看
但是,当我构建项目时,我会得到以下输出:
Started by <user>
Building in workspace /Users/Shared/Jenkins/Home/workspace/Tutorial
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@github.com:<url>.git # timeout=10
Fetching upstream changes from git@github.com:<url>.git
> git --version # timeout=10
> git fetch --tags --progress git@github.com:<url>.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision b62c3e873be4fba3daa1b29a9954a130c768a8f4 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f b62c3e873be4fba3daa1b29a9954a130c768a8f4
> git rev-list b62c3e873be4fba3daa1b29a9954a130c768a8f4 # timeout=10
[Tutorial] $ /bin/bash /Users/Shared/Jenkins/tmp/hudson719949293776127111.sh
/Users/Shared/Jenkins/tmp/hudson719949293776127111.sh: line 4: behave: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
然后在Jenkins构建步骤中使用代码
/run.sh
运行脚本,而不是behave
或我在注释中提到的变体,但我得到了相同的错误。我最终找到了答案。我使用Shining Panda插件创建了一个VirtualNV,需要在构建步骤中激活它。为了避免每次构建项目时都创建一个新的virtualenv,我创建了一个新作业,该作业刚刚创建了一个新的virtualenv。该作业中的配置生成步骤如下所示:
然后,在我之前创建的作业中,执行Shell步骤如下所示:
在哪里
/Users/Shared/Jenkins/Home/shiningpanda/jobs/ae39534a/virtualenvs/d41d8cd9/bin/activate
是创建的virtualenv的直接路径。然后,我就可以运行behave了。在作业中调用behave时,您是否尝试过包含behave的完整路径?@Jacob我尝试了代码
源项目/bin/behave
,并得到错误消息命令未找到
exec project/bin/behave
和project/bin/behave
yield没有这样的文件或目录
和未定义的错误:0
错误,但我知道behave在目录中找到。如果你没有注意到我只是在尝试一切。
Started by <user>
Building in workspace /Users/Shared/Jenkins/Home/workspace/Tutorial
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@github.com:<url>.git # timeout=10
Fetching upstream changes from git@github.com:<url>.git
> git --version # timeout=10
> git fetch --tags --progress git@github.com:<url>.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision b62c3e873be4fba3daa1b29a9954a130c768a8f4 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f b62c3e873be4fba3daa1b29a9954a130c768a8f4
> git rev-list b62c3e873be4fba3daa1b29a9954a130c768a8f4 # timeout=10
[Tutorial] $ /bin/bash /Users/Shared/Jenkins/tmp/hudson719949293776127111.sh
/Users/Shared/Jenkins/tmp/hudson719949293776127111.sh: line 4: behave: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
#!/bin/sh
exec project/bin/behave