繁体   English   中英

Travis CI,Rails不在根目录中

[英]Travis CI with Rails Not In Root Directory

我有一个Rails项目设置,其目录结构如下:

研究/ my_rails_app

研究根目录有一些帮助脚本和我希望包含在版本控制下的其他东西,但不是Rails应用程序本身的一部分。 我希望在Travis CI中使用CI,该项目在Github上托管。 我是特拉维斯CI的新手,所以如果这是一个愚蠢的问题...请耐心等待。 我的.travis.yml文件如下:

language: ruby
rvm:
  - 1.9.3
script: bundle rake rspec twitter_analysis/spec
services: 
  -mongodb
before_script:
  - psql -c 'create database test-postgres_production;' -U test-postgres
gemfile:
  - /twitter_analysis/Gemfile

Travis尝试构建时的错误消息是:

The command "psql -c 'create database test-postgres_production;' -U test-postgres" failed and exited with 2 during before_script.

另一个是:

-mongodb: unrecognized service

rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

我该如何解决这个问题?

我会尝试解决您应该一次更改一个错误的问题。

一个错误

The command "psql -c 'create database test-postgres_production;' -U test-postgres" failed and exited with 2 during before_script.

让我们添加以下内容以获得Travis CI上的postgres数据库:

env:
  - DB=postgresql
script:
  - bundle exec rake db:migrate
  - bundle exec rake db:test:prepare
  - bundle exec rake spec
before_script:
  - bundle exec rake db:create RAILS_ENV=test

现在我们正在运行rake tast来创建数据库,你应该能够删除你在before_script:当前拥有的内容before_script:

现在为第二个错误

-mongodb: unrecognized service

我想你在mongodb之前需要一个空间,如下所示:

services: 
  - mongodb

并且第三个也是最后一个错误

rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

我之前没有遇到过这个问题,但是我听说无法解析你的.travis.yml。 仔细检查它是否是一个有效的YAML文件,拼写正确且位置正确。 你能确认它在应用程序的根目录中并命名为.travis.yml吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM