Alternate way Automated node.js Deployments to Bluemix via Jenkins

After having used the CloudFoundry plugin for Jenkins for a bit we found that the BM API was periodically erroring out and returning such things as:

400 Bad Request
and Read timed out
502 Bad Gateway

So I installed the cf tools on the jenkins server and was many times able to get successful build pushed to bluemix by running an Excecute Shell in the Build Step with the following commands:

cd public;
npm install;
gulp build;
cd ../;
sudo cf api;
sudo cf login -u [email protected] -o -s staging -p password;
sudo cf push MyNodeApp-staging;

If you are binding to services, like mongodb, the trick is to have a manifest.yml file in the root of the project (should be in .gitignore if you pushing multiple branches) In this case the manifest looks like:

- services:
  - mongodb-H
  disk_quota: 1024M
  host: MyNodeApp-staging
  name: MyNodeApp-staging
  path: .
  instances: 1
  memory: 256M
  NODE_ENV: staging

Where the service name to bind to is specified and the environment variable NODE_ENV is passed through for the application to handle environmental case switching.

One thought on “Alternate way Automated node.js Deployments to Bluemix via Jenkins

Leave a Reply

Your email address will not be published. Required fields are marked *