Capistrano 测试 运行 失败,但部署成功
Capistrano test run failed, but deployment successful
我已经为我的 rails 项目部署设置了 Capistrano,我正在 运行 我的单元测试来自如下自定义上限任务。
namespace :deploy do
desc "Runs test before deploying, can't deploy unless they pass"
task :run_tests do
puts "--> Running tests, please wait ..."
unless system "bundle exec rake > log/capistrano.log 2>&1" #' > /dev/null'
puts "--> Tests failed. Run `cat log/capistrano.log` to see what went wrong."
exit
else
puts "--> Tests passed"
end
puts "--> All tests passed"
end
end
如果系统中存在单元测试失败,部署将不会继续进行,但在 jenkins
中构建显示为蓝色。这意味着构建成功。
如何通知 jenkins
构建以错误结束?
您在 "tests failed" 分支中 运行 exit
,这将结束 ruby 程序,状态代码为零(成功!)。
如果您从 ruby exit 1
(或任何非零值),詹金斯就会知道发生了一些不好的事情。
"exit unsuccessfully" 在 ruby 中还有其他方法(如 raise),但退出就像在 bash 中一样。
我已经为我的 rails 项目部署设置了 Capistrano,我正在 运行 我的单元测试来自如下自定义上限任务。
namespace :deploy do
desc "Runs test before deploying, can't deploy unless they pass"
task :run_tests do
puts "--> Running tests, please wait ..."
unless system "bundle exec rake > log/capistrano.log 2>&1" #' > /dev/null'
puts "--> Tests failed. Run `cat log/capistrano.log` to see what went wrong."
exit
else
puts "--> Tests passed"
end
puts "--> All tests passed"
end
end
如果系统中存在单元测试失败,部署将不会继续进行,但在 jenkins
中构建显示为蓝色。这意味着构建成功。
如何通知 jenkins
构建以错误结束?
您在 "tests failed" 分支中 运行 exit
,这将结束 ruby 程序,状态代码为零(成功!)。
如果您从 ruby exit 1
(或任何非零值),詹金斯就会知道发生了一些不好的事情。
"exit unsuccessfully" 在 ruby 中还有其他方法(如 raise),但退出就像在 bash 中一样。