使用Jenkins进行Yii Codeception测试

时间:2016-08-08 12:02:32

标签: php bash shell jenkins yii2

我正在尝试使用Jenkins自动化Yii 2测试。由于测试最近是分散的,我希望看到所有测试立即运行。为此,我创建了一个小shell脚本

test-all.sh

#!/bin/bash
which codecept
for i in */tests
do
    i=${i%tests}
    cd "$i"
    codecept run --fail-fast
    cd ../
done

当从命令行(Git Bash)运行时,测试运行正常。但是,当我在Jenkins中运行此文件时,虽然构建返回SUCCESSfully,但是没有运行任何测试。

[CI] $ "C:\Program Files\Git\usr\bin\sh.exe" -xe C:\Windows\TEMP\hudson8239762865441374376.sh
+ cd /c/xampp/htdocs/mtnt-2
+ /usr/bin/bash test-all.sh
/c/xampp/htdocs/mtnt-2
test-all.sh: line 3: which: command not found
test-all.sh: line 8: codecept: command not found
test-all.sh: line 8: codecept: command not found
test-all.sh: line 8: codecept: command not found
test-all.sh: line 8: codecept: command not found
Finished: SUCCESS

似乎找不到which变量中的codecept命令和PATH命令。

我该如何解决这个问题?

更新

到目前为止,我已尝试更改主节点的路径。这也不够。我通过Jenkins -> Manage Jenkins -> System Information确认全局Composer供应商bin的路径包含在Path变量中。

我还尝试在项目中本地codeception。因此,新的test-all.sh脚本是

#!/bin/bash
ROOT_FOLDER=`pwd`
for i in */tests
do
    i=${i%tests}
    cd "`pwd`/$i"
    $ROOT_FOLDER/vendor/bin/codecept run --fail-fast
    cd ../
done

现在,我收到以下错误。

[CI] $ "C:\Program Files\Git\usr\bin\bash.exe" -xe C:\Windows\TEMP\hudson2613836971033972638.sh
+ cd /c/xampp/htdocs/mtnt-2/
+ ./test-all.sh
/usr/bin/env: sh: No such file or directory
/usr/bin/env: sh: No such file or directory
/usr/bin/env: sh: No such file or directory
/usr/bin/env: sh: No such file or directory
Finished: SUCCESS

0 个答案:

没有答案