我使用 node.js 和 mocha 插件。我需要从 Jenkins 运行测试。
测试目录是'/home/user/tests' 通过putty我可以启动命令'make all'来运行测试并得到结果。如何从 bash 脚本运行它?
我在文件“start.sh”中创建了脚本:
#!/bin/bash
DIR=$(cd /home/user/tests; make all)
echo "-----------------------START----$stDate--------------------"
echo $DIR
echo "------------------------END-----$enDate--------------------"
在这种情况下,结果是
08:10:58 SSH: EXEC: STDOUT/STDERR from command [start.sh] ...
08:10:59 /bin/sh: mocha: command not found
08:10:59 /bin/sh: mocha: command not found
08:10:59 /bin/sh: mocha: command not found
08:10:59 /bin/sh: line 0: cd: ./messagel: No such file or directory
08:10:59 -----------------------START----Mon Sep 3 08:11:00 EDT 2012--------------------
08:10:59 cd ./tenant; mocha; cd ../; cd ./user; mocha --reporter list; cd ../; cd ./asset; mocha; cd ../; cd ./messagel mocha -t 5000; cd ../;
08:10:59 ------------------------END-----Mon Sep 3 08:11:00 EDT 2012--------------------
08:10:59 SSH: EXEC: completed after 401 ms
但这包含在文件“makefile”中,并且不运行 cd ./tenant;摩卡;光盘../;cd ./用户;摩卡——记者名单;光盘../;cd ./资产;摩卡;光盘../;cd ./messagel mocha -t 5000;光盘../;