5

I am trying to build a node.js project in travis-ci. this is my .travis.yml file:

language: node_js
node_js:
  - 0.8

after_script:
  # Install the Heroku package (or the Heroku toolbelt)
  - npm install heroku
  # Add your Heroku git repo:
  - git remote add heroku git@heroku.com:*****.git
  # Add your Heroku API key:
  - export HEROKU_API_KEY=KEYHERE
  # Turn off warnings about SSH keys:
  - echo "Host heroku.com" >> ~/.ssh/config
  - echo "   StrictHostKeyChecking no" >> ~/.ssh/config
  - echo "   CheckHostIP no" >> ~/.ssh/config
  - echo "   UserKnownHostsFile=/dev/null" >> ~/.ssh/config
  # Clear your current Heroku SSH keys:
  - heroku keys:clear
  # Add a new SSH key to Heroku
  - yes | heroku keys:add
  # Push to Heroku!
  - yes | git push heroku master

I get the following build error right on the beginning:

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

Probably because there's something wrong with my yml file and it tries to use the default ruby builder.

I don't think the file is not valid yml file as I have checked it with yml validator at http://yamllint.com/

Something wrong with my Travis specific conf ?

My package.json looks like this :

{
  "name": "csnc",
  "description": "csnc",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "3.x",
    "ejs": ">=0.0.0",
    "express-partials": ">=0.0.0"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}

EDIT:

If you are looking for a way to automatically deploy node.js app to Heroku using Travis-CI, look for the answer I included for a working .travis.yml file

Michael
  • 22,196
  • 33
  • 132
  • 187
  • 1
    Are you using NPM? If so, how does your package.json look like? – Odi Nov 21 '12 at 08:57
  • @Odi added the file to the question – Michael Nov 21 '12 at 09:13
  • If I'm not wrong travis will call `npm test` if you define node_js as language, but you didn't specify in your package.json `"scripts" : {"test": "./my_test_script.js" }`. Or what do you expect to be called? – Odi Nov 21 '12 at 11:57
  • @Odi I've created a test and added it to `package.json` still didn't help. Travis is still using ruby worker: ruby2.worker.travis-ci.org:ruby-4. Also found this issue with lint.travis-ci : https://github.com/travis-ci/travis-lint/issues/8 but it was fixed so don't know how to debug this anymore – Michael Nov 21 '12 at 12:17
  • 1
    Well this is just a fix for travis-lint, this actually is not a problem of travis, but just with the linting tool. There are projects on travis with `node_js: 0.8` that work. – Odi Nov 21 '12 at 12:26
  • Any chance to get a link to your repository? – Odi Nov 21 '12 at 12:34
  • @Odi Thanks man, I'm still not sure what just went here, but I discovered a stray space in the beginning of the file that must have caused problems. – Michael Nov 21 '12 at 12:48

2 Answers2

6

Your .travis.yml file does not validate; you can validate it at http://lint.travis-ci.org/.

Found an issue with the node_js key:

Detected unsupported Node.js versions. For an up-to-date list of supported Node.js versions, see Travis CI documentation at http://bit.ly/travis-ci-environment

Try using 0.8.x.

Michelle Tilley
  • 157,729
  • 40
  • 374
  • 311
  • thanks for the tool, very useful. after changing to `0.8.x` i still get an issue with node_js key and the build results are the same.Changing the version to `0.6` however solves it. Travis says in the docs that 0.8 is supported so I don't understand – Michael Nov 21 '12 at 09:07
  • Marking this as the answer because this is what got me closest to finding the problem with my file – Michael Nov 21 '12 at 12:52
1

For some weird reason, I have noticed a single space at the beginning of the file that wasn't there before (I swear :). This is what must have caused the error.

The weird thing was that when I was changing node version from 0.8 to 0.6 the validator didn't notice the error. Maybe it's a bug in the validator.

Anyway, I have also succeeded in automating the deployment of my node app to Heroku. I haven't found any documentation around the web regarding the process of doing it (specifically for node), so I am attaching the .travis.yml file that worked for me. Notice that I didn't have to add any tests for my app, it worked fine without it:

language: node_js
node_js:
  - 0.8

after_script:
  # Install the Heroku package (or the Heroku toolbelt)
  - npm install heroku
  # Add your Heroku git repo:
  - git remote add heroku git@heroku.com:HEROKU_REPO_HERE.git
  # Add your Heroku API key:
  - export HEROKU_API_KEY=ENTER_KEY_HERE
  # Turn off warnings about SSH keys:
  - echo "Host heroku.com" >> ~/.ssh/config
  - echo "   StrictHostKeyChecking no" >> ~/.ssh/config
  - echo "   CheckHostIP no" >> ~/.ssh/config
  - echo "   UserKnownHostsFile=/dev/null" >> ~/.ssh/config
  # Download and install Heroku toolbelt locally
  - wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
  # Clear your current Heroku SSH keys:
  - heroku keys:clear
  # Add a new SSH key to Heroku
  - yes | heroku keys:add
  # Push to Heroku!
  - yes | git push heroku master

EDIT:

I have recently moved from Travis.ci to Drone.io. If you are looking for a automatic deployment to Heroku from Github, you should check it out, It works great and was easier to set up IMO.

https://drone.io/

Michael
  • 22,196
  • 33
  • 132
  • 187
  • 1
    Oh snap, glad you figured it out. Because of the heroku-thing, I previuosly [described the steps in another answer](http://stackoverflow.com/a/12849594/549755). You could improve your scripts by [encrypting your `HEROKU_API_KEY`](http://stackoverflow.com/questions/9338428/using-secret-api-keys-on-travis-ci/12778315#12778315). – Odi Nov 21 '12 at 13:06
  • @Odi good point, I am struggling with installing ruby and travis gem to make this thing work. Is there an easier way ? – Michael Nov 21 '12 at 16:30
  • Not that I know of. `gem install travis` is pretty easy I'd say. If your having troubles with it, you should post another question on SO. – Odi Nov 21 '12 at 16:49
  • I'm having this problem https://github.com/travis-ci/travis-cli/pull/4#issuecomment-10011211 – Michael Nov 21 '12 at 17:14
  • This should no longer be a problem, because it has been fixed in the latest version of the gem. – Odi Nov 21 '12 at 17:39