One of our new clients is a partner of IBM and we are building a node.js-based application for them. Through their IBM partnership they were encouraged to leverage IBM’s Bluemix Cloud Foundry-based PaaS for development and deployment. We have plenty of experience with virtualized environments and are always interested in exploring new technologies and platforms. However, with the client’s best interest and budget taken to heart, we decided to try and use as much of our existing workflow and process as possible rather than spending a ton of hours getting ramped on the bluemix DevOps platform.

So we have our codebase checked into bitbucket just like every other project and we are running jenkins hooks to our CI server to trigger builds on check in. There a wonderful Jenkins plugin for Cloud Foundry code pushes, which works perfectly for pushing to Bluemix – https://wiki.jenkins-ci.org/display/JENKINS/Cloud+Foundry+Plugin

Once the plugin is installed via Jenkins plugin manager, it should appear as a “Post Build Action” in the project configuration screen. (If you install the plugin and that option does not show up, Jenkins is likely pointed at a java version prior to 1.7 – you can confirm this by looking in the jenkins logfile for an error about “Unsupported major.minor version 51.0″)

Once you get the option, you simply add your bluemix credentials via the credential manager, then set up the Cloud Foundry post build action with the correct values for the parameters:

Capture

And the web app gets pushed to bluemix, which takes care of all the vendor dependencies and deploys the app!

Checking out Revision d846a37fc9b234f37713005dc88a7ba78855f3d6 (origin/staging)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f d846a37fc9b234f37713005dc88a7ba78855f3d6
 > git rev-list d846a37fc9b234f37713005dc88a7ba78855f3d6 # timeout=10
Cloud Foundry Plugin:
Pushing SDStaging app to https://api.ng.bluemix.net
App already exists, resetting.
App deleted.
Creating new app.
Pushing app bits.
Starting application.
       Installing IBM SDK for Node.js (0.12.2) from cache
       Using default npm version: 2.7.4
-----> Checking and configuring service extensions before installing dependencies
-----> Building dependencies
       Installing node modules
       > (node-gyp rebuild 2> builderror.log) || (exit 0)
       > [email protected] install /tmp/staged/app/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
       make: Entering directory `/tmp/staged/app/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/build'
         CXX(target) Release/obj.target/kerberos/lib/kerberos.o
         CXX(target) Release/obj.target/kerberos/lib/worker.o
         CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
         CC(target) Release/obj.target/kerberos/lib/base64.o
         CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
         SOLINK_MODULE(target) Release/obj.target/kerberos.node
         SOLINK_MODULE(target) Release/obj.target/kerberos.node: Finished
         COPY Release/kerberos.node
       make: Leaving directory `/tmp/staged/app/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/build'
       > (node-pre-gyp install --fallback-to-build) || (node-gyp rebuild 2> builderror.log) || (exit 0)
       > [email protected] install /tmp/staged/app/node_modules/mongoose/node_modules/bson/node_modules/bson-ext
       make: Entering directory `/tmp/staged/app/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/build'
         CXX(target) Release/obj.target/bson/ext/bson.o
         SOLINK_MODULE(target) Release/obj.target/bson.node
         SOLINK_MODULE(target) Release/obj.target/bson.node: Finished
         COPY Release/bson.node
       make: Leaving directory `/tmp/staged/app/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/build'
       [email protected] node_modules/vhost
       [email protected] node_modules/debug
       └── [email protected]
       [email protected] node_modules/cookie-parser
       └── [email protected]
       ├── [email protected]
       └── [email protected]
       ├── [email protected]
       ├── [email protected]
       └── [email protected]
       [email protected] node_modules/serve-favicon
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       [email protected] node_modules/passport
       [email protected] node_modules/body-parser
       └── [email protected] ([email protected])
       [email protected] node_modules/morgan
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected] ([email protected])
       ├── [email protected] ([email protected])
       ├── [email protected] ([email protected], [email protected])
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       [email protected] node_modules/express
       └── [email protected] ([email protected], [email protected])
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected] ([email protected], [email protected].0.1)
       ├── [email protected]
       ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
       ├── [email protected]
       ├── [email protected] ([email protected])
       [email protected] node_modules/hbs
       ├── [email protected] ([email protected])
       [email protected] node_modules/mongoose
       ├── [email protected] ([email protected], [email protected])
       ├── [email protected]
       ├── [email protected]
       ├── [email protected] ([email protected])
       └── [email protected] ([email protected], [email protected], [email protected])
       ├── [email protected]
       └── [email protected] ([email protected], [email protected])
       ├── [email protected]
       ├── [email protected]
       └── [email protected] ([email protected])
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected] ([email protected])
       ├── [email protected]
       ├── [email protected] ([email protected], [email protected])
-----> Checking startup method
       No Procfile; Adding 'web: npm start' to new Procfile
-----> Checking and configuring service extensions after installing dependencies
-----> Installing App Management
       Creating runtime environment
-----> Finalizing build
-----> Building runtime environment
       Caching results for future builds
       Cleaning previous cache
-----> Build succeeded!
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       ├── [email protected]
       [email protected] /tmp/staged/app
       ├── [email protected]
       └── [email protected]
       ├── [email protected]
       ├── [email protected]
       WARNING: Node version not specified in package.json